{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "079736e7",
   "metadata": {},
   "source": [
    "### 8.2 一元线性回归"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "94040859",
   "metadata": {},
   "source": [
    "#### 8.2.3 对women数据集进行线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "920681ee",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.linear_model import LinearRegression\n",
    "from sklearn.metrics import mean_squared_error, r2_score\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "8a17938b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "斜率 (m): 3.555906756222835\n",
      "截距 (b): -94.43026471750281\n",
      "均方误差 (MSE): 4.77238091209106\n",
      "决定系数 (R^2): 0.9787158433058377\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEGCAYAAACKB4k+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAvk0lEQVR4nO3deXSUVbb38e8OowhOEEeE4IDeMIgYEbFtQWnEVtEW9cVFt3NHHFBbnLkqDmlBnFpUFAXRa8TLRXFqR1QaUVFBARHEkSGIMgkCkSnZ7x+nkqqEBEKSSlUlv89aWVbtp4ZdHbp2znOes4+5OyIiIgBpiU5ARESSh4qCiIgUU1EQEZFiKgoiIlJMRUFERIrVT3QCVdGiRQvPyMhIdBoiIillxowZK9w9vaxjKV0UMjIymD59eqLTEBFJKWa2sLxjOn0kIiLFVBRERKSYioKIiBRL6TmFsmzevJm8vDw2bNiQ6FSkBjRu3JiWLVvSoEGDRKciUivUuqKQl5dHs2bNyMjIwM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zDOPHjwdg7ty55X55n3DCCUyYMIFly5YBoQ34woULWbFiBYWFhfTt25e77rqLzz//nMLCQhYvXkyPHj0YNmwYa9asYd26dSVer1u3bsXblubm5nLsscfu0OcTibfly8Pp6LIKwosvho6mtaEggEYKcZGfn0/Lli2L719zzTUVet7FF1/MggUL6Ny5M+5Oeno6L730Ev379+fUU0+lQ4cOZGVlceihh+5wTjvttBODBg1i+PDhPPzww1x99dV07NiRwsJC2rRpw2uvvcZll13GeeedR2ZmJoceeijt2rVj11133eq1MjMzueuuu+jVqxeFhYU0aNCARx55hJ122okLLriAwsJCAO6++24KCgr461//ypo1a3B3rrzySnbbbbcSrzdixAguuOAChg8fTnp6Ok899dQOfz6ReBk8GP75z63jbdvCV1+FvRBqk7h1Sa0J6pJavQoKCti8eTONGzfm+++/p2fPnsyfP5+GDRsmOrVt0u9c4mHhQsjIKPvY5Mlw3HE1mU31SkiXVEk9+fn59OjRg82bN+PuPProo0lfEETi4aKLYMyYrePdu8N778X3ysZEU1GQYs2aNaP0yEukLpkzBzp0KPvYF19AzFXatVatnGhO5VNismP0u5bq4A69e5ddEM45JxyvCwUB4lgUzGyMmS0zszllHBtkZm5mLSL3u5vZGjObGfm5tbLv27hxY1auXKkvizrA3Vm5ciWNGzdOdCqSwj76CNLS4K23tj723XdhkVpdEs/TR2OBh4ESXeDMbH+gF7Co1OM/cPdTqvqmLVu2JC8vj+XLl1f1pSQFNG7cuMSVXiIVVVAAhx8OZV15PWgQRNZ21jnx3I5ziplllHHoAeB64OV4vG+DBg1o06ZNPF5aRGqJf/8bTinnT9ClS2HvvWs2n2RSo3MKZnYasMTdZ5Vx+Ggzm2Vmb5hZu228RraZTTez6RoNiMiO2LABWrQouyDcc0+YO6jLBQFq8OojM2sC3Ew4dVTa50Brd19nZn8GXgIOLut13H0UMArCOoX4ZCsitc0zz8B555V9bPVqKGOdZp1UkyOFA4E2wCwzWwC0BD43s73d/Td3Xwfg7q8DDYomoUVEquK338K6grIKwlNPhdGBCkJ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PZilQPFQWRauTur7j70Cq8xNWAioIkjIqCSCWYWbqZvWBmn0V+jonEi0cTZnZgpLf+l2Z2V6mRR9OYXvy5FlwJ7Au8b2bvJ+BjidSZFc0ilbGTmc2Mub8HoX0IwL+AB9x9qpm1Iux98F+lnv8v4F/uPs7MSq+2PhxoR2iL8CFwjLs/ZGbXAD3cPeVaP0jtoKIgUr7f3b1T0Z1IA76syN2eQGZMg89dzKxpqecfTXQfi+cIrZSLfOrueZHXnQlkAFOrLXORSlJREKmcNKCru2+IDe5AF+iNMbcL0P8XJUloTkGkct4mNEQDwn7fZTxmGtA3crtfBV93LdCsSpmJVIGKgkjlXAlkmdlsM5sLlNWh9WrgGjObDRwErKnA644C3tREsySKuqSKxElkvcHv7u5m1g84x91PS3ReItui85gi8XME8HBku8nVhL2kRZKaRgoiIlJMcwoiIlJMRUFERIqpKIiISDEVBRERKaaiICIixf4/XTDp+Bhl6psAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 创建women数据集\n",
    "data = {'height': [58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72],\n",
    "        'weight': [115, 117, 120, 123, 126, 129, 132, 135, 139, 142, 146, 150, 154, 159, 164]}\n",
    "\n",
    "women_df = pd.DataFrame(data)\n",
    "\n",
    "# 划分数据集\n",
    "X = women_df[['height']]\n",
    "y = women_df['weight']\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
    "\n",
    "# 创建线性回归模型\n",
    "model = LinearRegression()\n",
    "\n",
    "# 拟合模型\n",
    "model.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "y_pred = model.predict(X_test)\n",
    "\n",
    "# 评估模型\n",
    "mse = mean_squared_error(y_test, y_pred)\n",
    "r2 = r2_score(y_test, y_pred)\n",
    "\n",
    "# 输出模型参数\n",
    "print(\"斜率 (m):\", model.coef_[0])\n",
    "print(\"截距 (b):\", model.intercept_)\n",
    "print(\"均方误差 (MSE):\", mse)\n",
    "print(\"决定系数 (R^2):\", r2)\n",
    "\n",
    "# 绘制拟合曲线\n",
    "plt.scatter(X_test, y_test, color='black', label='Actual')\n",
    "plt.plot(X_test, y_pred, color='blue', linewidth=3, label='Linear Regression')\n",
    "plt.xlabel('Height')\n",
    "plt.ylabel('Weight')\n",
    "plt.legend()\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9f1fc3ca",
   "metadata": {},
   "source": [
    "### 8.3\t多元线性回归"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6f3461d6",
   "metadata": {},
   "source": [
    "#### 8.3.2 对个人医疗费用进行多元线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "2af04ab7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>sex</th>\n",
       "      <th>bmi</th>\n",
       "      <th>children</th>\n",
       "      <th>smoker</th>\n",
       "      <th>region</th>\n",
       "      <th>charges</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>female</td>\n",
       "      <td>27.900</td>\n",
       "      <td>0</td>\n",
       "      <td>yes</td>\n",
       "      <td>southwest</td>\n",
       "      <td>16884.92400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>18</td>\n",
       "      <td>male</td>\n",
       "      <td>33.770</td>\n",
       "      <td>1</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>1725.55230</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>28</td>\n",
       "      <td>male</td>\n",
       "      <td>33.000</td>\n",
       "      <td>3</td>\n",
       "      <td>no</td>\n",
       "      <td>southeast</td>\n",
       "      <td>4449.46200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>male</td>\n",
       "      <td>22.705</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>21984.47061</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>32</td>\n",
       "      <td>male</td>\n",
       "      <td>28.880</td>\n",
       "      <td>0</td>\n",
       "      <td>no</td>\n",
       "      <td>northwest</td>\n",
       "      <td>3866.85520</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age     sex     bmi  children smoker     region      charges\n",
       "0   19  female  27.900         0    yes  southwest  16884.92400\n",
       "1   18    male  33.770         1     no  southeast   1725.55230\n",
       "2   28    male  33.000         3     no  southeast   4449.46200\n",
       "3   33    male  22.705         0     no  northwest  21984.47061\n",
       "4   32    male  28.880         0     no  northwest   3866.85520"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 导入并查看前五行\n",
    "import numpy as np\n",
    "import pandas as pd \n",
    "insurance = pd.read_excel('data/insurance.xlsx') \n",
    "insurance.head() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "3670113c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "斜率: [239.99 332.08 542.86]\n",
      "截距: -6916.24\n",
      "决定系数: 0.12\n"
     ]
    }
   ],
   "source": [
    "# 方式一：使用LinearRegression类\n",
    "\n",
    "# 构建自变量X和因变量y\n",
    "X = insurance[[ 'age', 'bmi', 'children']]\n",
    "y = insurance['charges']\n",
    "\n",
    "# 实例化及训练模型\n",
    "model = LinearRegression().fit(X,y)\n",
    "\n",
    "# 预测\n",
    "y_pred = model.predict(X)\n",
    "\n",
    "# 评估模型\n",
    "r2 = r2_score(y, y_pred)\n",
    "\n",
    "# 输出模型参数\n",
    "print(\"斜率:\", np.round(model.coef_,2))\n",
    "print(\"截距:\", np.round(model.intercept_,2))\n",
    "print(\"决定系数:\", np.round(r2,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "f3e3dffd",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\Program\\Anaconda3\\lib\\site-packages\\statsmodels\\tsa\\base\\tsa_model.py:7: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.\n",
      "  from pandas import (to_datetime, Int64Index, DatetimeIndex, Period,\n",
      "D:\\Program\\Anaconda3\\lib\\site-packages\\statsmodels\\tsa\\base\\tsa_model.py:7: FutureWarning: pandas.Float64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.\n",
      "  from pandas import (to_datetime, Int64Index, DatetimeIndex, Period,\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "回归系数：\n",
      " const      -6916.243348\n",
      "age          239.994474\n",
      "bmi          332.083365\n",
      "children     542.864652\n",
      "dtype: float64\n",
      "决定系数：\n",
      " 0.1200981957624695\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\Program\\Anaconda3\\lib\\site-packages\\statsmodels\\tsa\\tsatools.py:142: FutureWarning: In a future version of pandas all arguments of concat except for the argument 'objs' will be keyword-only.\n",
      "  x = pd.concat(x[::order], 1)\n"
     ]
    }
   ],
   "source": [
    "# 方式二：使用OLS类实现\n",
    "import statsmodels.api as sm \n",
    "\n",
    "# 添加常数项列，用于拟合截距\n",
    "insurance_df = sm.add_constant(insurance)\n",
    "\n",
    "# 定义因变量和自变量\n",
    "endog = insurance_df['charges']\n",
    "exog = insurance_df[['const', 'age', 'bmi', 'children']]\n",
    "\n",
    "# 使用OLS进行多元线性回归\n",
    "model1 = sm.OLS(endog, exog)\n",
    "results = model1.fit()\n",
    "\n",
    "# 打印回归系数\n",
    "print('回归系数：\\n',results.params)\n",
    "# 打印决定系数\n",
    "print('决定系数：\\n',results.rsquared)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "84ec81bf",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "回归系数：\n",
      " Intercept   -6916.243348\n",
      "age           239.994474\n",
      "bmi           332.083365\n",
      "children      542.864652\n",
      "dtype: float64\n",
      "决定系数：\n",
      " 0.1200981957624696\n"
     ]
    }
   ],
   "source": [
    "# 方式二：使用ols函数实现\n",
    "import statsmodels.api as sm \n",
    "# 构建线性回归模型\n",
    "model2 = sm.formula.ols('charges ~ age + bmi + children',data=insurance).fit()\n",
    "# 打印回归系数\n",
    "print('回归系数：\\n',model2.params)\n",
    "# 打印决定系数\n",
    "print('决定系数：\\n',model2.rsquared)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "814884bb",
   "metadata": {},
   "source": [
    "### 8.4 自变量有定性变量的回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "db843563",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "查看原数据集前五行:\n",
      "    age     sex     bmi  children      charges\n",
      "0   19  female  27.900         0  16884.92400\n",
      "1   18    male  33.770         1   1725.55230\n",
      "2   28    male  33.000         3   4449.46200\n",
      "3   33    male  22.705         0  21984.47061\n",
      "4   32    male  28.880         0   3866.85520\n",
      "查看虚拟变量处理后前五行：\n",
      "    age     bmi  children      charges  sex_female  sex_male\n",
      "0   19  27.900         0  16884.92400           1         0\n",
      "1   18  33.770         1   1725.55230           0         1\n",
      "2   28  33.000         3   4449.46200           0         1\n",
      "3   33  22.705         0  21984.47061           0         1\n",
      "4   32  28.880         0   3866.85520           0         1\n"
     ]
    }
   ],
   "source": [
    "df = insurance.loc[:,['age', 'sex', 'bmi', 'children', 'charges']] # 提取数据子集\n",
    "df_dummy = pd.get_dummies(df) # 对类别变量进行虚拟变量处理\n",
    "print('查看原数据集前五行:\\n',df.head()) # 查看原数据集前五行\n",
    "print('查看虚拟变量处理后前五行：\\n',df_dummy.head()) # 查看虚拟变量处理后的前五行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "1616da10",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>male</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   male\n",
       "0     0\n",
       "1     1\n",
       "2     1\n",
       "3     1\n",
       "4     1"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.get_dummies(df['sex'], drop_first=True).head() # 仅对变量sex做处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "a35f00e9",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "回归系数：\n",
      " const      -7459.969598\n",
      "age          241.263511\n",
      "sex_male    1321.719782\n",
      "bmi          326.761491\n",
      "children     533.168130\n",
      "dtype: float64\n",
      "决定系数：\n",
      " 0.12306876681889367\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\Program\\Anaconda3\\lib\\site-packages\\statsmodels\\tsa\\tsatools.py:142: FutureWarning: In a future version of pandas all arguments of concat except for the argument 'objs' will be keyword-only.\n",
      "  x = pd.concat(x[::order], 1)\n"
     ]
    }
   ],
   "source": [
    "# 通过OLS类构建多元线性回归模型\n",
    "# 将性别转换为虚拟变量（0和1）\n",
    "df = pd.get_dummies(df, drop_first=True)\n",
    "\n",
    "# 添加截距项\n",
    "X = sm.add_constant(df[['age', 'sex_male', 'bmi', 'children']])\n",
    "y = df['charges']\n",
    "\n",
    "# 拟合多元线性回归模型\n",
    "model = sm.OLS(y, X).fit()\n",
    "\n",
    "# 打印回归系数\n",
    "print('回归系数：\\n',model.params)\n",
    "# 打印决定系数\n",
    "print('决定系数：\\n',model.rsquared)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "91647564",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "斜率: [ 241.26 1321.72  326.76  533.17]\n",
      "截距: -7459.97\n",
      "决定系数: 0.12\n"
     ]
    }
   ],
   "source": [
    "# 通过Scikit-Learn的LinearRegression类实现\n",
    "# 构建自变量X和因变量y\n",
    "X = df[['age', 'sex_male', 'bmi', 'children']]\n",
    "y = df['charges']\n",
    "\n",
    "# 实例化及训练模型\n",
    "model = LinearRegression().fit(X,y)\n",
    "\n",
    "# 预测\n",
    "y_pred = model.predict(X)\n",
    "\n",
    "# 评估模型\n",
    "r2 = r2_score(y, y_pred)\n",
    "\n",
    "# 输出模型参数\n",
    "print(\"斜率:\", np.round(model.coef_,2))\n",
    "print(\"截距:\", np.round(model.intercept_,2))\n",
    "print(\"决定系数:\", np.round(r2,2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "5bc4df89",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>age</th>\n",
       "      <th>bmi</th>\n",
       "      <th>children</th>\n",
       "      <th>charges</th>\n",
       "      <th>sex_male</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19</td>\n",
       "      <td>27.900</td>\n",
       "      <td>0</td>\n",
       "      <td>16884.92400</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>18</td>\n",
       "      <td>33.770</td>\n",
       "      <td>1</td>\n",
       "      <td>1725.55230</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>28</td>\n",
       "      <td>33.000</td>\n",
       "      <td>3</td>\n",
       "      <td>4449.46200</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>22.705</td>\n",
       "      <td>0</td>\n",
       "      <td>21984.47061</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>32</td>\n",
       "      <td>28.880</td>\n",
       "      <td>0</td>\n",
       "      <td>3866.85520</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   age     bmi  children      charges  sex_male\n",
       "0   19  27.900         0  16884.92400         0\n",
       "1   18  33.770         1   1725.55230         1\n",
       "2   28  33.000         3   4449.46200         1\n",
       "3   33  22.705         0  21984.47061         1\n",
       "4   32  28.880         0   3866.85520         1"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "231ba319",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "回归系数：\n",
      " Intercept   -7459.969598\n",
      "age           241.263511\n",
      "sex_male     1321.719782\n",
      "bmi           326.761491\n",
      "children      533.168130\n",
      "dtype: float64\n",
      "决定系数：\n",
      " 0.12306876681889367\n"
     ]
    }
   ],
   "source": [
    "# 通过ols函数构建线性回归模型\n",
    "model = sm.formula.ols('charges ~ age + sex_male + bmi+children',data=df).fit()\n",
    "\n",
    "# 打印回归系数\n",
    "print('回归系数：\\n',model.params)\n",
    "# 打印决定系数\n",
    "print('决定系数：\\n',model.rsquared)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "7c3792fb",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                            OLS Regression Results                            \n",
      "==============================================================================\n",
      "Dep. Variable:                charges   R-squared:                       0.123\n",
      "Model:                            OLS   Adj. R-squared:                  0.120\n",
      "Method:                 Least Squares   F-statistic:                     46.77\n",
      "Date:                  周日, 28 1月 2024   Prob (F-statistic):           8.05e-37\n",
      "Time:                        15:17:15   Log-Likelihood:                -14390.\n",
      "No. Observations:                1338   AIC:                         2.879e+04\n",
      "Df Residuals:                    1333   BIC:                         2.882e+04\n",
      "Df Model:                           4                                         \n",
      "Covariance Type:            nonrobust                                         \n",
      "==============================================================================\n",
      "                 coef    std err          t      P>|t|      [0.025      0.975]\n",
      "------------------------------------------------------------------------------\n",
      "Intercept  -7459.9696   1773.722     -4.206      0.000   -1.09e+04   -3980.380\n",
      "age          241.2635     22.268     10.835      0.000     197.580     284.947\n",
      "sex_male    1321.7198    621.995      2.125      0.034     101.523    2541.916\n",
      "bmi          326.7615     51.304      6.369      0.000     226.116     427.407\n",
      "children     533.1681    257.942      2.067      0.039      27.152    1039.185\n",
      "==============================================================================\n",
      "Omnibus:                      321.539   Durbin-Watson:                   2.022\n",
      "Prob(Omnibus):                  0.000   Jarque-Bera (JB):              592.267\n",
      "Skew:                           1.506   Prob(JB):                    2.46e-129\n",
      "Kurtosis:                       4.243   Cond. No.                         293.\n",
      "==============================================================================\n",
      "\n",
      "Notes:\n",
      "[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n"
     ]
    }
   ],
   "source": [
    "# 输出模型摘要\n",
    "print(model.summary())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6dfe37da",
   "metadata": {},
   "source": [
    "### 8.5 逐步回归寻找最优模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "95bfd355",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Start:  AIC=23316.59\n",
      "charges ~ age + sex + bmi + children + smoker + region\n",
      "\n",
      "           Df  Sum of Sq        RSS   AIC\n",
      "- sex       1 5.8130e+06 4.8851e+10 23315\n",
      "<none>                   4.8845e+10 23317\n",
      "- region    3 2.3847e+08 4.9084e+10 23317\n",
      "- children  1 4.4261e+08 4.9288e+10 23327\n",
      "- bmi       1 5.1634e+09 5.4009e+10 23449\n",
      "- age       1 1.7144e+10 6.5989e+10 23717\n",
      "- smoker    1 1.2255e+11 1.7140e+11 24994\n",
      "\n",
      "Step:  AIC=23314.75\n",
      "charges ~ age + bmi + children + smoker + region\n",
      "\n",
      "           Df  Sum of Sq        RSS   AIC\n",
      "<none>                   4.8851e+10 23315\n",
      "- region    3 2.3822e+08 4.9090e+10 23315\n",
      "- children  1 4.4099e+08 4.9292e+10 23325\n",
      "- bmi       1 5.1586e+09 5.4010e+10 23447\n",
      "- age       1 1.7170e+10 6.6022e+10 23716\n",
      "- smoker    1 1.2312e+11 1.7197e+11 24997\n",
      "\n",
      "Call:\n",
      "(function (formula, data, subset, weights, na.action, method = \"qr\", \n",
      "    model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, \n",
      "    contrasts = NULL, offset, ...) \n",
      "{\n",
      "    ret.x <- x\n",
      "    ret.y <- y\n",
      "    cl <- match.call()\n",
      "    mf <- match.call(expand.dots = FALSE)\n",
      "    m <- match(c(\"formula\", \"data\", \"subset\", \"weights\", \"na.action\", \n",
      "        \"offset\"), names(mf), 0L)\n",
      "    mf <- mf[c(1L, m)]\n",
      "    mf$drop.unused.levels <- TRUE\n",
      "    mf[[1L]] <- quote(stats::model.frame)\n",
      "    mf <- eval(mf, parent.frame())\n",
      "    if (method == \"model.frame\") \n",
      "        return(mf)\n",
      "    else if (method != \"qr\") \n",
      "        warning(gettextf(\"method = '%s' is not supported. Using 'qr'\", \n",
      "            method), domain = NA)\n",
      "    mt <- attr(mf, \"terms\")\n",
      "    y <- model.response(mf, \"numeric\")\n",
      "    w <- as.vector(model.weights(mf))\n",
      "    if (!is.null(w) && !is.numeric(w)) \n",
      "        stop(\"'weights' must be a numeric vector\")\n",
      "    offset <- model.offset(mf)\n",
      "    mlm <- is.matrix(y)\n",
      "    ny <- if (mlm) \n",
      "        nrow(y)\n",
      "    else length(y)\n",
      "    if (!is.null(offset)) {\n",
      "        if (!mlm) \n",
      "            offset <- as.vector(offset)\n",
      "        if (NROW(offset) != ny) \n",
      "            stop(gettextf(\"number of offsets is %d, should equal %d (number of observations)\", \n",
      "                NROW(offset), ny), domain = NA)\n",
      "    }\n",
      "    if (is.empty.model(mt)) {\n",
      "        x <- NULL\n",
      "        z <- list(coefficients = if (mlm) matrix(NA_real_, 0, \n",
      "            ncol(y)) else numeric(), residuals = y, fitted.values = 0 * \n",
      "            y, weights = w, rank = 0L, df.residual = if (!is.null(w)) sum(w != \n",
      "            0) else ny)\n",
      "        if (!is.null(offset)) {\n",
      "            z$fitted.values <- offset\n",
      "            z$residuals <- y - offset\n",
      "        }\n",
      "    }\n",
      "    else {\n",
      "        x <- model.matrix(mt, mf, contrasts)\n",
      "        z <- if (is.null(w)) \n",
      "            lm.fit(x, y, offset = offset, singular.ok = singular.ok, \n",
      "                ...)\n",
      "        else lm.wfit(x, y, w, offset = offset, singular.ok = singular.ok, \n",
      "            ...)\n",
      "    }\n",
      "    class(z) <- c(if (mlm) \"mlm\", \"lm\")\n",
      "    z$na.action <- attr(mf, \"na.action\")\n",
      "    z$offset <- offset\n",
      "    z$contrasts <- attr(x, \"contrasts\")\n",
      "    z$xlevels <- .getXlevels(mt, mf)\n",
      "    z$call <- cl\n",
      "    z$terms <- mt\n",
      "    if (model) \n",
      "        z$model <- mf\n",
      "    if (ret.x) \n",
      "        z$x <- x\n",
      "    if (ret.y) \n",
      "        z$y <- y\n",
      "    if (!qr) \n",
      "        z$qr <- NULL\n",
      "    z\n",
      "})(formula = charges ~ age + bmi + children + smoker + region, \n",
      "    data = structure(list(age = c(19L, 18L, 28L, 33L, 32L, 31L, \n",
      "    46L, 37L, 37L, 60L, 25L, 62L, 23L, 56L, 27L, 19L, 52L, 23L, \n",
      "    56L, 30L, 60L, 30L, 18L, 34L, 37L, 59L, 63L, 55L, 23L, 31L, \n",
      "    22L, 18L, 19L, 63L, 28L, 19L, 62L, 26L, 35L, 60L, 24L, 31L, \n",
      "    41L, 37L, 38L, 55L, 18L, 28L, 60L, 36L, 18L, 21L, 48L, 36L, \n",
      "    40L, 58L, 58L, 18L, 53L, 34L, 43L, 25L, 64L, 28L, 20L, 19L, \n",
      "    61L, 40L, 40L, 28L, 27L, 31L, 53L, 58L, 44L, 57L, 29L, 21L, \n",
      "    22L, 41L, 31L, 45L, 22L, 48L, 37L, 45L, 57L, 56L, 46L, 55L, \n",
      "    21L, 53L, 59L, 35L, 64L, 28L, 54L, 55L, 56L, 38L, 41L, 30L, \n",
      "    18L, 61L, 34L, 20L, 19L, 26L, 29L, 63L, 54L, 55L, 37L, 21L, \n",
      "    52L, 60L, 58L, 29L, 49L, 37L, 44L, 18L, 20L, 44L, 47L, 26L, \n",
      "    19L, 52L, 32L, 38L, 59L, 61L, 53L, 19L, 20L, 22L, 19L, 22L, \n",
      "    54L, 22L, 34L, 26L, 34L, 29L, 30L, 29L, 46L, 51L, 53L, 19L, \n",
      "    35L, 48L, 32L, 42L, 40L, 44L, 48L, 18L, 30L, 50L, 42L, 18L, \n",
      "    54L, 32L, 37L, 47L, 20L, 32L, 19L, 27L, 63L, 49L, 18L, 35L, \n",
      "    24L, 63L, 38L, 54L, 46L, 41L, 58L, 18L, 22L, 44L, 44L, 36L, \n",
      "    26L, 30L, 41L, 29L, 61L, 36L, 25L, 56L, 18L, 19L, 39L, 45L, \n",
      "    51L, 64L, 19L, 48L, 60L, 27L, 46L, 28L, 59L, 35L, 63L, 40L, \n",
      "    20L, 40L, 24L, 34L, 45L, 41L, 53L, 27L, 26L, 24L, 34L, 53L, \n",
      "    32L, 19L, 42L, 55L, 28L, 58L, 41L, 47L, 42L, 59L, 19L, 59L, \n",
      "    39L, 40L, 18L, 31L, 19L, 44L, 23L, 33L, 55L, 40L, 63L, 54L, \n",
      "    60L, 24L, 19L, 29L, 18L, 63L, 54L, 27L, 50L, 55L, 56L, 38L, \n",
      "    51L, 19L, 58L, 20L, 52L, 19L, 53L, 46L, 40L, 59L, 45L, 49L, \n",
      "    18L, 50L, 41L, 50L, 25L, 47L, 19L, 22L, 59L, 51L, 40L, 54L, \n",
      "    30L, 55L, 52L, 46L, 46L, 63L, 59L, 52L, 28L, 29L, 25L, 22L, \n",
      "    25L, 18L, 19L, 47L, 31L, 48L, 36L, 53L, 56L, 28L, 57L, 29L, \n",
      "    28L, 30L, 58L, 41L, 50L, 19L, 43L, 49L, 27L, 52L, 50L, 54L, \n",
      "    44L, 32L, 34L, 26L, 34L, 57L, 29L, 40L, 27L, 45L, 64L, 52L, \n",
      "    61L, 52L, 61L, 56L, 43L, 64L, 60L, 62L, 50L, 46L, 24L, 62L, \n",
      "    60L, 63L, 49L, 34L, 33L, 46L, 36L, 19L, 57L, 50L, 30L, 33L, \n",
      "    18L, 46L, 46L, 47L, 23L, 18L, 48L, 35L, 19L, 21L, 21L, 49L, \n",
      "    56L, 42L, 44L, 18L, 61L, 57L, 42L, 26L, 20L, 23L, 39L, 24L, \n",
      "    64L, 62L, 27L, 55L, 55L, 35L, 44L, 19L, 58L, 50L, 26L, 24L, \n",
      "    48L, 19L, 48L, 49L, 46L, 46L, 43L, 21L, 64L, 18L, 51L, 47L, \n",
      "    64L, 49L, 31L, 52L, 33L, 47L, 38L, 32L, 19L, 44L, 26L, 25L, \n",
      "    19L, 43L, 52L, 36L, 64L, 63L, 64L, 61L, 40L, 25L, 48L, 45L, \n",
      "    38L, 18L, 21L, 27L, 19L, 29L, 42L, 60L, 31L, 60L, 22L, 35L, \n",
      "    52L, 26L, 31L, 33L, 18L, 59L, 56L, 45L, 60L, 56L, 40L, 35L, \n",
      "    39L, 30L, 24L, 20L, 32L, 59L, 55L, 57L, 56L, 40L, 49L, 42L, \n",
      "    62L, 56L, 19L, 30L, 60L, 56L, 28L, 18L, 27L, 18L, 19L, 47L, \n",
      "    54L, 61L, 24L, 25L, 21L, 23L, 63L, 49L, 18L, 51L, 48L, 31L, \n",
      "    54L, 19L, 44L, 53L, 19L, 61L, 18L, 61L, 21L, 20L, 31L, 45L, \n",
      "    44L, 62L, 29L, 43L, 51L, 19L, 38L, 37L, 22L, 21L, 24L, 57L, \n",
      "    56L, 27L, 51L, 19L, 39L, 58L, 20L, 45L, 35L, 31L, 50L, 32L, \n",
      "    51L, 38L, 42L, 18L, 19L, 51L, 46L, 18L, 57L, 62L, 59L, 37L, \n",
      "    64L, 38L, 33L, 46L, 46L, 53L, 34L, 20L, 63L, 54L, 54L, 49L, \n",
      "    28L, 54L, 25L, 43L, 63L, 32L, 62L, 52L, 25L, 28L, 46L, 34L, \n",
      "    35L, 19L, 46L, 54L, 27L, 50L, 18L, 19L, 38L, 41L, 49L, 48L, \n",
      "    31L, 18L, 30L, 62L, 57L, 58L, 22L, 31L, 52L, 25L, 59L, 19L, \n",
      "    39L, 32L, 19L, 33L, 21L, 34L, 61L, 38L, 58L, 47L, 20L, 21L, \n",
      "    41L, 46L, 42L, 34L, 43L, 52L, 18L, 51L, 56L, 64L, 19L, 51L, \n",
      "    27L, 59L, 28L, 30L, 47L, 38L, 18L, 34L, 20L, 47L, 56L, 49L, \n",
      "    19L, 55L, 30L, 37L, 49L, 18L, 59L, 29L, 36L, 33L, 58L, 44L, \n",
      "    53L, 24L, 29L, 40L, 51L, 64L, 19L, 35L, 39L, 56L, 33L, 42L, \n",
      "    61L, 23L, 43L, 48L, 39L, 40L, 18L, 58L, 49L, 53L, 48L, 45L, \n",
      "    59L, 52L, 26L, 27L, 48L, 57L, 37L, 57L, 32L, 18L, 64L, 43L, \n",
      "    49L, 40L, 62L, 40L, 30L, 29L, 36L, 41L, 44L, 45L, 55L, 60L, \n",
      "    56L, 49L, 21L, 19L, 39L, 53L, 33L, 53L, 42L, 40L, 47L, 27L, \n",
      "    21L, 47L, 20L, 24L, 27L, 26L, 53L, 41L, 56L, 23L, 21L, 50L, \n",
      "    53L, 34L, 47L, 33L, 51L, 49L, 31L, 36L, 18L, 50L, 43L, 20L, \n",
      "    24L, 60L, 49L, 60L, 51L, 58L, 51L, 53L, 62L, 19L, 50L, 30L, \n",
      "    41L, 29L, 18L, 41L, 35L, 53L, 24L, 48L, 59L, 49L, 37L, 26L, \n",
      "    23L, 29L, 45L, 27L, 53L, 31L, 50L, 50L, 34L, 19L, 47L, 28L, \n",
      "    37L, 21L, 64L, 58L, 24L, 31L, 39L, 47L, 30L, 18L, 22L, 23L, \n",
      "    33L, 27L, 45L, 57L, 47L, 42L, 64L, 38L, 61L, 53L, 44L, 19L, \n",
      "    41L, 51L, 40L, 45L, 35L, 53L, 30L, 18L, 51L, 50L, 31L, 35L, \n",
      "    60L, 21L, 29L, 62L, 39L, 19L, 22L, 53L, 39L, 27L, 30L, 30L, \n",
      "    58L, 33L, 42L, 64L, 21L, 18L, 23L, 45L, 40L, 19L, 18L, 25L, \n",
      "    46L, 33L, 54L, 28L, 36L, 20L, 24L, 23L, 47L, 33L, 45L, 26L, \n",
      "    18L, 44L, 60L, 64L, 56L, 36L, 41L, 39L, 63L, 36L, 28L, 58L, \n",
      "    36L, 42L, 36L, 56L, 35L, 59L, 21L, 59L, 23L, 57L, 53L, 60L, \n",
      "    51L, 23L, 27L, 55L, 37L, 61L, 46L, 53L, 49L, 20L, 48L, 25L, \n",
      "    25L, 57L, 37L, 38L, 55L, 36L, 51L, 40L, 18L, 57L, 61L, 25L, \n",
      "    50L, 26L, 42L, 43L, 44L, 23L, 49L, 33L, 41L, 37L, 22L, 23L, \n",
      "    21L, 51L, 25L, 32L, 57L, 36L, 22L, 57L, 64L, 36L, 54L, 47L, \n",
      "    62L, 61L, 43L, 19L, 18L, 19L, 49L, 60L, 26L, 49L, 60L, 26L, \n",
      "    27L, 44L, 63L, 32L, 22L, 18L, 59L, 44L, 33L, 24L, 43L, 45L, \n",
      "    61L, 35L, 62L, 62L, 38L, 34L, 43L, 50L, 19L, 57L, 62L, 41L, \n",
      "    26L, 39L, 46L, 45L, 32L, 59L, 44L, 39L, 18L, 53L, 18L, 50L, \n",
      "    18L, 19L, 62L, 56L, 42L, 37L, 42L, 25L, 57L, 51L, 30L, 44L, \n",
      "    34L, 31L, 54L, 24L, 43L, 48L, 19L, 29L, 63L, 46L, 52L, 35L, \n",
      "    51L, 44L, 21L, 39L, 50L, 34L, 22L, 19L, 26L, 29L, 48L, 26L, \n",
      "    45L, 36L, 54L, 34L, 31L, 27L, 20L, 44L, 43L, 45L, 34L, 24L, \n",
      "    26L, 38L, 50L, 38L, 27L, 39L, 39L, 63L, 33L, 36L, 30L, 24L, \n",
      "    24L, 48L, 47L, 29L, 28L, 47L, 25L, 51L, 48L, 43L, 61L, 48L, \n",
      "    38L, 59L, 19L, 26L, 54L, 21L, 51L, 22L, 47L, 18L, 47L, 21L, \n",
      "    19L, 23L, 54L, 37L, 46L, 55L, 30L, 18L, 61L, 54L, 22L, 45L, \n",
      "    22L, 19L, 35L, 18L, 20L, 28L, 55L, 43L, 43L, 22L, 25L, 49L, \n",
      "    44L, 64L, 49L, 47L, 27L, 55L, 48L, 45L, 24L, 32L, 24L, 57L, \n",
      "    59L, 36L, 29L, 42L, 48L, 39L, 63L, 54L, 37L, 63L, 21L, 54L, \n",
      "    60L, 32L, 47L, 21L, 28L, 63L, 18L, 32L, 38L, 32L, 62L, 39L, \n",
      "    55L, 57L, 52L, 56L, 47L, 55L, 23L, 22L, 50L, 18L, 51L, 22L, \n",
      "    52L, 25L, 33L, 53L, 29L, 58L, 37L, 54L, 49L, 50L, 26L, 45L, \n",
      "    54L, 38L, 48L, 28L, 23L, 55L, 41L, 25L, 33L, 30L, 23L, 46L, \n",
      "    53L, 27L, 23L, 63L, 55L, 35L, 34L, 19L, 39L, 27L, 57L, 52L, \n",
      "    28L, 50L, 44L, 26L, 33L, 19L, 50L, 41L, 52L, 39L, 50L, 52L, \n",
      "    60L, 20L, 55L, 42L, 18L, 58L, 43L, 35L, 48L, 36L, 19L, 23L, \n",
      "    20L, 32L, 43L, 34L, 30L, 18L, 41L, 35L, 57L, 29L, 32L, 37L, \n",
      "    18L, 43L, 56L, 38L, 29L, 22L, 52L, 40L, 23L, 31L, 42L, 24L, \n",
      "    25L, 48L, 23L, 45L, 20L, 62L, 43L, 23L, 31L, 41L, 58L, 48L, \n",
      "    31L, 19L, 19L, 41L, 40L, 31L, 37L, 46L, 22L, 51L, 18L, 35L, \n",
      "    59L, 36L, 37L, 59L, 36L, 39L, 18L, 52L, 27L, 18L, 40L, 29L, \n",
      "    46L, 38L, 30L, 40L, 50L, 20L, 41L, 33L, 38L, 42L, 56L, 58L, \n",
      "    52L, 20L, 54L, 58L, 45L, 26L, 63L, 58L, 37L, 25L, 52L, 64L, \n",
      "    22L, 28L, 18L, 28L, 45L, 33L, 18L, 32L, 24L, 19L, 20L, 40L, \n",
      "    34L, 42L, 51L, 54L, 55L, 52L, 32L, 28L, 41L, 43L, 49L, 64L, \n",
      "    55L, 24L, 20L, 45L, 26L, 25L, 43L, 35L, 26L, 57L, 22L, 32L, \n",
      "    39L, 25L, 48L, 47L, 18L, 18L, 61L, 47L, 28L, 36L, 20L, 44L, \n",
      "    38L, 19L, 21L, 46L, 58L, 20L, 18L, 28L, 33L, 19L, 45L, 62L, \n",
      "    25L, 43L, 42L, 24L, 29L, 32L, 25L, 41L, 42L, 33L, 34L, 19L, \n",
      "    30L, 18L, 19L, 18L, 35L, 39L, 31L, 62L, 62L, 42L, 31L, 61L, \n",
      "    42L, 51L, 23L, 52L, 57L, 23L, 52L, 50L, 18L, 18L, 21L, 61L\n",
      "    ), sex = c(\"female\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"male\", \"male\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"male\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"male\", \"female\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"male\", \"male\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"female\", \"male\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"female\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"female\", \"male\", \"female\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"male\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"male\", \"female\", \"male\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"female\", \"female\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"female\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"male\", \"female\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"female\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"male\", \"female\", \"female\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"female\", \"female\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"male\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"female\", \"female\", \"female\", \"female\", \"male\", \n",
      "    \"female\", \"male\", \"male\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"male\", \"male\", \"male\", \n",
      "    \"male\", \"female\", \"female\", \"male\", \"female\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"female\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"female\", \"male\", \"female\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"female\", \"male\", \"male\", \"female\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"female\", \"female\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"female\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"male\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"female\", \"male\", \"female\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"male\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"female\", \"male\", \"male\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"male\", \"female\", \"female\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"female\", \"male\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"male\", \"male\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"male\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"male\", \"female\", \"male\", \"male\", \n",
      "    \"female\", \"male\", \"female\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"female\", \"male\", \"female\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"male\", \"male\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"male\", \"female\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"female\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"female\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"female\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"female\", \"female\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"male\", \"male\", \"male\", \"female\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"female\", \"female\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"female\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"female\", \"female\", \"female\", \"male\", \n",
      "    \"female\", \"male\", \"female\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"female\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"female\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"female\", \"female\", \"male\", \"female\", \"male\", \"male\", \n",
      "    \"female\", \"male\", \"female\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"male\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"male\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"female\", \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"male\", \"female\", \"female\", \"female\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"male\", \"female\", \"female\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"female\", \"female\", \"male\", \"female\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"female\", \"female\", \"female\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"male\", \"female\", \"male\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"female\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"male\", \"male\", \"male\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"female\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"male\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"male\", \"female\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"male\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"female\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"female\", \"female\", \"male\", \"female\", \"female\", \"male\", \n",
      "    \"male\", \"female\", \"female\", \"male\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"female\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"female\", \"female\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"female\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"male\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"male\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"female\", \"male\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"male\", \"female\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"male\", \"female\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"male\", \"female\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"male\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"male\", \"female\", \"male\", \"female\", \"male\", \"male\", \n",
      "    \"male\", \"female\", \"female\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"male\", \"male\", \"male\", \"male\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"female\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"female\", \"female\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"male\", \"male\", \"male\", \"male\", \n",
      "    \"male\", \"female\", \"male\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"male\", \"female\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"female\", \"female\", \"male\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"male\", \"female\", \"male\", \"male\", \n",
      "    \"female\", \"male\", \"female\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"male\", \"male\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"male\", \"male\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"female\", \"female\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"male\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"female\", \"female\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"female\", \"female\", \"male\", \"male\", \n",
      "    \"female\", \"male\", \"female\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"female\", \"male\", \"male\", \"male\", \"male\", \n",
      "    \"female\", \"male\", \"male\", \"female\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"female\", \"female\", \"female\", \"male\", \n",
      "    \"female\", \"male\", \"female\", \"male\", \"female\", \"female\", \"male\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"female\", \"female\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"female\", \"female\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"male\", \"male\", \"male\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"male\", \"male\", \"female\", \"female\", \"female\", \"male\", \n",
      "    \"male\", \"female\", \"male\", \"female\", \"male\", \"male\", \"male\", \n",
      "    \"male\", \"male\", \"female\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"male\", \"female\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"female\", \"female\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"female\", \"male\", \"female\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"male\", \"female\", \"male\", \"male\", \n",
      "    \"female\", \"male\", \"male\", \"male\", \"male\", \"female\", \"female\", \n",
      "    \"male\", \"female\", \"female\", \"female\", \"female\", \"male\", \"male\", \n",
      "    \"female\", \"female\", \"female\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"male\", \"male\", \"male\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"male\", \"male\", \"female\", \"male\", \"male\", \"female\", \n",
      "    \"female\", \"male\", \"female\", \"male\", \"male\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"male\", \"female\", \"male\", \"male\", \"female\", \n",
      "    \"male\", \"male\", \"male\", \"female\", \"male\", \"male\", \"female\", \n",
      "    \"male\", \"female\", \"male\", \"female\", \"female\", \"female\", \"male\", \n",
      "    \"female\", \"female\", \"female\", \"female\"), bmi = c(27L, 33L, \n",
      "    33L, 22L, 28L, 25L, 33L, 27L, 29L, 25L, 26L, 26L, 34L, 39L, \n",
      "    42L, 24L, 30L, 23L, 40L, 35L, 36L, 32L, 34L, 31L, 28L, 27L, \n",
      "    23L, 32L, 17L, 36L, 35L, 26L, 28L, 28L, 36L, 20L, 32L, 20L, \n",
      "    36L, 39L, 26L, 36L, 21L, 30L, 37L, 37L, 38L, 34L, 24L, 35L, \n",
      "    35L, 33L, 28L, 34L, 28L, 36L, 31L, 31L, 22L, 37L, 27L, 33L, \n",
      "    24L, 25L, 22L, 28L, 39L, 26L, 36L, 23L, 24L, 28L, 28L, 32L, \n",
      "    27L, 34L, 29L, 35L, 39L, 32L, 26L, 38L, 37L, 41L, 34L, 22L, \n",
      "    31L, 27L, 27L, 26L, 39L, 24L, 29L, 34L, 31L, 37L, 30L, 38L, \n",
      "    19L, 19L, 31L, 25L, 30L, 29L, 27L, 28L, 28L, 30L, 27L, 35L, \n",
      "    33L, 29L, 30L, 35L, 32L, 28L, 49L, 27L, 27L, 23L, 37L, 23L, \n",
      "    28L, 31L, 33L, 28L, 28L, 37L, 17L, 34L, 26L, 22L, 35L, 25L, \n",
      "    28L, 28L, 34L, 25L, 31L, 36L, 22L, 32L, 25L, 29L, 28L, 38L, \n",
      "    30L, 37L, 37L, 28L, 24L, 29L, 37L, 23L, 25L, 39L, 24L, 25L, \n",
      "    35L, 27L, 26L, 36L, 39L, 29L, 29L, 28L, 37L, 33L, 31L, 18L, \n",
      "    41L, 30L, 15L, 34L, 33L, 37L, 27L, 29L, 28L, 33L, 28L, 38L, \n",
      "    19L, 26L, 30L, 41L, 29L, 30L, 32L, 32L, 31L, 26L, 25L, 26L, \n",
      "    34L, 30L, 32L, 28L, 18L, 39L, 32L, 32L, 24L, 36L, 22L, 28L, \n",
      "    26L, 27L, 31L, 41L, 33L, 30L, 28L, 26L, 30L, 37L, 26L, 23L, \n",
      "    29L, 23L, 33L, 33L, 30L, 34L, 24L, 33L, 38L, 41L, 31L, 25L, \n",
      "    36L, 27L, 17L, 27L, 24L, 22L, 26L, 38L, 29L, 38L, 36L, 22L, \n",
      "    26L, 35L, 27L, 30L, 38L, 35L, 20L, 28L, 17L, 32L, 34L, 30L, \n",
      "    31L, 25L, 33L, 40L, 24L, 31L, 25L, 26L, 24L, 36L, 38L, 42L, \n",
      "    19L, 32L, 30L, 25L, 29L, 34L, 37L, 27L, 27L, 26L, 20L, 24L, \n",
      "    31L, 21L, 28L, 40L, 27L, 32L, 31L, 26L, 48L, 26L, 36L, 26L, \n",
      "    33L, 29L, 45L, 28L, 26L, 22L, 27L, 25L, 34L, 28L, 27L, 22L, \n",
      "    37L, 33L, 38L, 33L, 27L, 33L, 34L, 33L, 26L, 24L, 35L, 35L, \n",
      "    31L, 33L, 32L, 32L, 27L, 37L, 25L, 29L, 30L, 40L, 27L, 34L, \n",
      "    23L, 36L, 33L, 36L, 36L, 27L, 31L, 28L, 35L, 34L, 25L, 27L, \n",
      "    32L, 27L, 27L, 30L, 27L, 36L, 41L, 29L, 35L, 33L, 29L, 27L, \n",
      "    23L, 25L, 27L, 35L, 38L, 27L, 43L, 29L, 41L, 20L, 32L, 30L, \n",
      "    21L, 26L, 21L, 30L, 32L, 24L, 32L, 30L, 21L, 22L, 33L, 32L, \n",
      "    33L, 28L, 24L, 40L, 30L, 31L, 17L, 30L, 33L, 43L, 22L, 34L, \n",
      "    39L, 25L, 22L, 30L, 35L, 37L, 31L, 31L, 32L, 19L, 34L, 31L, \n",
      "    25L, 38L, 20L, 47L, 32L, 32L, 20L, 38L, 24L, 23L, 21L, 30L, \n",
      "    17L, 20L, 17L, 23L, 35L, 35L, 34L, 22L, 39L, 26L, 33L, 35L, \n",
      "    32L, 30L, 30L, 24L, 27L, 29L, 16L, 30L, 33L, 20L, 26L, 30L, \n",
      "    28L, 33L, 31L, 28L, 46L, 29L, 32L, 33L, 43L, 36L, 26L, 33L, \n",
      "    29L, 25L, 29L, 38L, 29L, 24L, 23L, 29L, 46L, 37L, 30L, 30L, \n",
      "    39L, 33L, 36L, 30L, 38L, 25L, 25L, 28L, 28L, 33L, 24L, 24L, \n",
      "    32L, 30L, 29L, 33L, 25L, 28L, 28L, 35L, 36L, 32L, 41L, 37L, \n",
      "    31L, 39L, 34L, 31L, 21L, 28L, 38L, 31L, 32L, 25L, 25L, 43L, \n",
      "    25L, 27L, 23L, 28L, 23L, 39L, 34L, 26L, 23L, 30L, 28L, 30L, \n",
      "    31L, 23L, 25L, 28L, 32L, 33L, 22L, 30L, 28L, 35L, 35L, 30L, \n",
      "    31L, 30L, 27L, 44L, 33L, 37L, 26L, 33L, 30L, 25L, 39L, 25L, \n",
      "    42L, 31L, 29L, 36L, 40L, 28L, 38L, 30L, 28L, 31L, 38L, 31L, \n",
      "    36L, 47L, 30L, 25L, 35L, 46L, 28L, 46L, 30L, 28L, 21L, 31L, \n",
      "    41L, 23L, 33L, 34L, 34L, 35L, 19L, 32L, 30L, 44L, 32L, 30L, \n",
      "    40L, 30L, 31L, 40L, 29L, 37L, 43L, 36L, 34L, 27L, 26L, 38L, \n",
      "    30L, 23L, 25L, 30L, 45L, 23L, 20L, 28L, 20L, 30L, 35L, 30L, \n",
      "    29L, 19L, 31L, 21L, 40L, 33L, 29L, 33L, 32L, 37L, 39L, 31L, \n",
      "    25L, 39L, 28L, 34L, 25L, 23L, 26L, 37L, 29L, 34L, 33L, 19L, \n",
      "    33L, 36L, 28L, 25L, 33L, 37L, 31L, 34L, 21L, 33L, 28L, 26L, \n",
      "    28L, 42L, 38L, 38L, 36L, 29L, 35L, 22L, 39L, 38L, 24L, 38L, \n",
      "    26L, 33L, 42L, 28L, 33L, 34L, 35L, 30L, 26L, 23L, 28L, 32L, \n",
      "    42L, 39L, 31L, 36L, 35L, 25L, 42L, 33L, 35L, 28L, 46L, 23L, \n",
      "    31L, 33L, 22L, 38L, 28L, 32L, 32L, 29L, 31L, 31L, 29L, 31L, \n",
      "    43L, 21L, 40L, 31L, 36L, 23L, 17L, 20L, 35L, 24L, 18L, 26L, \n",
      "    26L, 41L, 24L, 31L, 27L, 36L, 32L, 23L, 34L, 40L, 32L, 35L, \n",
      "    33L, 39L, 34L, 44L, 41L, 26L, 29L, 32L, 38L, 28L, 30L, 27L, \n",
      "    35L, 23L, 30L, 40L, 22L, 28L, 22L, 24L, 36L, 33L, 40L, 36L, \n",
      "    37L, 35L, 27L, 39L, 28L, 21L, 40L, 36L, 24L, 21L, 30L, 27L, \n",
      "    32L, 34L, 38L, 23L, 31L, 35L, 24L, 29L, 34L, 26L, 26L, 30L, \n",
      "    27L, 21L, 36L, 30L, 26L, 28L, 37L, 22L, 33L, 27L, 22L, 27L, \n",
      "    37L, 38L, 34L, 35L, 27L, 26L, 25L, 31L, 32L, 29L, 39L, 19L, \n",
      "    36L, 26L, 36L, 28L, 34L, 33L, 32L, 39L, 34L, 28L, 24L, 41L, \n",
      "    35L, 27L, 29L, 27L, 36L, 36L, 22L, 29L, 41L, 27L, 23L, 20L, \n",
      "    31L, 28L, 44L, 22L, 33L, 24L, 26L, 35L, 22L, 42L, 26L, 35L, \n",
      "    41L, 36L, 30L, 25L, 30L, 42L, 21L, 22L, 34L, 31L, 24L, 37L, \n",
      "    26L, 35L, 33L, 17L, 31L, 29L, 24L, 31L, 31L, 28L, 30L, 21L, \n",
      "    33L, 25L, 23L, 34L, 33L, 35L, 31L, 28L, 23L, 31L, 31L, 24L, \n",
      "    32L, 29L, 30L, 32L, 34L, 50L, 24L, 32L, 30L, 32L, 35L, 23L, \n",
      "    23L, 29L, 33L, 24L, 32L, 28L, 47L, 28L, 33L, 19L, 25L, 29L, \n",
      "    37L, 43L, 23L, 24L, 36L, 29L, 24L, 30L, 21L, 28L, 27L, 33L, \n",
      "    28L, 29L, 34L, 27L, 22L, 37L, 26L, 28L, 28L, 30L, 39L, 33L, \n",
      "    26L, 29L, 24L, 38L, 32L, 44L, 20L, 25L, 40L, 22L, 22L, 40L, \n",
      "    27L, 36L, 35L, 29L, 32L, 32L, 39L, 24L, 28L, 31L, 26L, 27L, \n",
      "    24L, 33L, 26L, 22L, 28L, 34L, 25L, 33L, 31L, 35L, 23L, 32L, \n",
      "    23L, 20L, 39L, 34L, 46L, 32L, 25L, 35L, 37L, 27L, 29L, 24L, \n",
      "    26L, 29L, 23L, 46L, 40L, 22L, 39L, 35L, 35L, 34L, 31L, 29L, \n",
      "    18L, 42L, 28L, 30L, 27L, 39L, 30L, 26L, 34L, 36L, 39L, 25L, \n",
      "    35L, 24L, 36L, 27L, 24L, 25L, 25L, 34L, 28L, 23L, 20L, 40L, \n",
      "    35L, 22L, 40L, 29L, 39L, 29L, 25L, 21L, 25L, 30L, 30L, 25L, \n",
      "    30L, 27L, 34L, 20L, 19L, 27L, 31L, 28L, 20L, 23L, 34L, 36L, \n",
      "    36L, 26L, 22L, 32L, 25L, 29L, 19L, 31L, 29L, 28L, 24L, 27L, \n",
      "    22L, 20L, 33L, 32L, 27L, 25L, 24L, 34L, 35L, 32L, 37L, 31L, \n",
      "    36L, 23L, 45L, 34L, 26L, 18L, 31L, 17L, 23L, 35L, 27L, 21L, \n",
      "    38L, 23L, 37L, 30L, 28L, 27L, 28L, 23L, 30L, 25L, 35L, 24L, \n",
      "    25L, 52L, 22L, 30L, 36L, 26L, 29L, 29L, 21L, 27L, 28L, 31L, \n",
      "    39L, 33L, 32L, 27L, 41L, 28L, 25L, 25L, 37L, 42L, 21L, 31L, \n",
      "    37L, 31L, 31L, 28L, 18L, 29L, 32L, 26L, 31L, 33L, 21L, 27L, \n",
      "    19L, 31L, 30L, 18L, 28L, 31L, 47L, 22L, 36L, 29L, 32L, 30L, \n",
      "    33L, 31L, 34L, 33L, 30L, 33L, 19L, 28L, 38L, 36L, 29L, 31L, \n",
      "    29L, 26L, 30L, 20L, 32L, 38L, 25L, 26L, 24L, 32L, 29L, 33L, \n",
      "    35L, 19L, 31L, 38L, 36L, 32L, 42L, 25L, 29L, 35L, 32L, 18L, \n",
      "    23L, 45L, 40L, 18L, 33L, 28L, 25L, 22L, 30L, 32L, 37L, 32L, \n",
      "    24L, 32L, 32L, 32L, 32L, 31L, 21L, 34L, 30L, 36L, 32L, 35L, \n",
      "    27L, 22L, 44L, 23L, 30L, 41L, 34L, 42L, 38L, 28L, 28L, 26L, \n",
      "    40L, 24L, 35L, 34L, 27L, 26L, 41L, 29L, 32L, 27L, 24L, 27L, \n",
      "    34L, 29L, 41L, 29L, 30L, 27L, 28L, 23L, 35L, 32L, 25L, 28L, \n",
      "    32L, 21L, 32L, 36L, 21L, 27L, 30L, 33L, 29L, 25L, 24L, 40L, \n",
      "    32L, 32L, 27L, 17L, 34L, 33L, 25L, 37L, 30L, 34L, 21L, 33L, \n",
      "    31L, 39L, 25L, 37L, 34L, 30L, 21L, 24L, 25L, 24L, 23L, 39L, \n",
      "    16L, 37L, 34L, 30L, 34L, 21L, 24L, 23L, 27L, 31L, 21L, 28L, \n",
      "    22L, 42L, 41L, 36L, 21L, 33L, 33L, 24L, 25L, 29L, 39L, 33L, \n",
      "    29L, 19L, 27L, 29L, 27L, 37L, 36L, 27L, 37L, 23L, 20L, 37L, \n",
      "    28L, 29L, 33L, 23L, 30L, 31L, 33L, 27L, 33L, 34L, 25L, 27L, \n",
      "    27L, 23L, 30L, 29L, 29L, 26L, 33L, 27L, 21L, 30L, 36L, 24L, \n",
      "    17L, 25L, 39L, 34L, 19L, 34L, 23L, 25L, 25L, 22L, 26L, 26L, \n",
      "    27L, 25L, 30L, 30L, 20L, 27L, 24L, 27L, 21L, 28L, 30L, 32L, \n",
      "    26L, 26L, 42L, 34L, 23L, 28L, 20L, 53L, 39L, 26L, 31L, 26L, \n",
      "    38L, 40L, 25L, 33L, 32L, 30L, 24L, 38L, 25L, 33L, 44L, 30L, \n",
      "    31L, 36L, 25L, 29L), children = c(0L, 1L, 3L, 0L, 0L, 0L, \n",
      "    1L, 3L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, \n",
      "    1L, 0L, 1L, 2L, 3L, 0L, 2L, 1L, 2L, 0L, 0L, 5L, 0L, 1L, 0L, \n",
      "    3L, 0L, 1L, 0L, 0L, 2L, 1L, 2L, 1L, 0L, 2L, 0L, 0L, 1L, 0L, \n",
      "    2L, 1L, 0L, 3L, 2L, 2L, 2L, 1L, 2L, 3L, 4L, 1L, 1L, 0L, 0L, \n",
      "    2L, 1L, 0L, 3L, 0L, 5L, 3L, 1L, 2L, 0L, 1L, 0L, 0L, 0L, 1L, \n",
      "    0L, 1L, 4L, 2L, 2L, 0L, 0L, 0L, 0L, 0L, 1L, 3L, 2L, 2L, 1L, \n",
      "    3L, 0L, 0L, 0L, 0L, 0L, 0L, 3L, 1L, 1L, 1L, 2L, 0L, 0L, 1L, \n",
      "    2L, 0L, 0L, 3L, 0L, 0L, 1L, 0L, 2L, 2L, 0L, 0L, 1L, 3L, 0L, \n",
      "    0L, 0L, 2L, 2L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 3L, 0L, 2L, \n",
      "    1L, 2L, 2L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 0L, 3L, 0L, 1L, 0L, \n",
      "    0L, 0L, 0L, 3L, 0L, 0L, 1L, 2L, 0L, 4L, 5L, 3L, 1L, 3L, 0L, \n",
      "    0L, 0L, 1L, 0L, 0L, 2L, 1L, 2L, 3L, 0L, 0L, 3L, 0L, 2L, 3L, \n",
      "    2L, 3L, 1L, 2L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, \n",
      "    1L, 0L, 0L, 0L, 1L, 0L, 2L, 0L, 1L, 1L, 4L, 2L, 1L, 2L, 2L, \n",
      "    0L, 0L, 1L, 0L, 1L, 0L, 3L, 0L, 0L, 3L, 0L, 0L, 1L, 2L, 1L, \n",
      "    3L, 0L, 1L, 2L, 2L, 0L, 2L, 0L, 1L, 2L, 1L, 1L, 3L, 0L, 0L, \n",
      "    0L, 0L, 1L, 1L, 2L, 2L, 2L, 3L, 0L, 3L, 0L, 0L, 4L, 0L, 0L, \n",
      "    1L, 3L, 0L, 3L, 3L, 1L, 3L, 1L, 1L, 1L, 2L, 2L, 1L, 0L, 2L, \n",
      "    2L, 0L, 2L, 1L, 1L, 3L, 1L, 1L, 0L, 1L, 2L, 0L, 1L, 3L, 0L, \n",
      "    1L, 2L, 0L, 3L, 0L, 0L, 1L, 3L, 1L, 3L, 3L, 2L, 2L, 2L, 2L, \n",
      "    2L, 1L, 0L, 2L, 0L, 0L, 3L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, \n",
      "    4L, 0L, 0L, 0L, 1L, 1L, 2L, 1L, 0L, 1L, 0L, 0L, 0L, 2L, 0L, \n",
      "    0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 4L, 3L, 2L, 1L, 1L, 0L, 0L, \n",
      "    0L, 0L, 0L, 0L, 0L, 3L, 3L, 0L, 0L, 2L, 1L, 0L, 1L, 2L, 1L, \n",
      "    3L, 2L, 2L, 3L, 0L, 0L, 1L, 2L, 0L, 0L, 3L, 0L, 3L, 1L, 2L, \n",
      "    0L, 0L, 2L, 2L, 0L, 0L, 2L, 0L, 3L, 4L, 0L, 1L, 1L, 2L, 0L, \n",
      "    3L, 0L, 2L, 0L, 0L, 1L, 0L, 3L, 0L, 2L, 0L, 1L, 3L, 1L, 0L, \n",
      "    1L, 2L, 5L, 0L, 1L, 0L, 2L, 1L, 0L, 0L, 0L, 1L, 0L, 2L, 5L, \n",
      "    1L, 0L, 1L, 3L, 0L, 2L, 0L, 0L, 1L, 3L, 0L, 3L, 5L, 0L, 1L, \n",
      "    0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 4L, 1L, 0L, 0L, 2L, 0L, \n",
      "    2L, 0L, 0L, 3L, 3L, 0L, 2L, 0L, 0L, 1L, 1L, 2L, 1L, 1L, 0L, \n",
      "    0L, 0L, 0L, 3L, 1L, 0L, 0L, 0L, 0L, 3L, 2L, 0L, 1L, 3L, 0L, \n",
      "    3L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 4L, 0L, 2L, 2L, 2L, 0L, 0L, \n",
      "    0L, 1L, 0L, 1L, 3L, 1L, 2L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, \n",
      "    1L, 2L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 2L, 1L, 1L, 0L, 1L, \n",
      "    0L, 2L, 0L, 0L, 1L, 3L, 2L, 1L, 0L, 3L, 2L, 0L, 0L, 0L, 2L, \n",
      "    0L, 2L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 2L, 1L, 0L, 3L, 0L, 2L, \n",
      "    0L, 0L, 1L, 2L, 0L, 1L, 2L, 5L, 2L, 0L, 1L, 2L, 1L, 2L, 0L, \n",
      "    0L, 1L, 1L, 0L, 1L, 0L, 2L, 1L, 0L, 1L, 3L, 1L, 0L, 1L, 0L, \n",
      "    1L, 2L, 1L, 0L, 1L, 2L, 1L, 2L, 2L, 0L, 0L, 0L, 3L, 0L, 0L, \n",
      "    0L, 0L, 2L, 2L, 1L, 2L, 0L, 3L, 0L, 1L, 0L, 2L, 0L, 0L, 1L, \n",
      "    4L, 1L, 0L, 0L, 0L, 3L, 1L, 0L, 0L, 1L, 0L, 0L, 2L, 1L, 0L, \n",
      "    1L, 2L, 0L, 4L, 5L, 3L, 0L, 3L, 2L, 3L, 1L, 3L, 0L, 0L, 2L, \n",
      "    1L, 0L, 2L, 0L, 2L, 1L, 2L, 1L, 4L, 3L, 1L, 1L, 0L, 0L, 2L, \n",
      "    1L, 2L, 0L, 1L, 3L, 0L, 0L, 0L, 2L, 0L, 3L, 3L, 3L, 2L, 1L, \n",
      "    0L, 2L, 0L, 1L, 2L, 2L, 0L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, \n",
      "    2L, 1L, 0L, 2L, 0L, 0L, 0L, 1L, 1L, 2L, 0L, 3L, 3L, 0L, 1L, \n",
      "    2L, 2L, 0L, 0L, 0L, 1L, 1L, 2L, 0L, 0L, 3L, 0L, 0L, 1L, 3L, \n",
      "    1L, 1L, 0L, 1L, 3L, 1L, 3L, 1L, 3L, 1L, 0L, 2L, 3L, 2L, 2L, \n",
      "    0L, 0L, 0L, 0L, 1L, 2L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 4L, 2L, \n",
      "    3L, 0L, 3L, 0L, 2L, 1L, 1L, 0L, 2L, 0L, 1L, 1L, 0L, 2L, 3L, \n",
      "    2L, 0L, 0L, 2L, 3L, 2L, 0L, 3L, 0L, 3L, 0L, 1L, 1L, 1L, 3L, \n",
      "    0L, 0L, 3L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 2L, 1L, 0L, 0L, 1L, \n",
      "    0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 3L, 3L, 2L, 2L, 2L, 0L, \n",
      "    0L, 3L, 1L, 0L, 1L, 0L, 0L, 2L, 0L, 2L, 2L, 1L, 3L, 1L, 0L, \n",
      "    0L, 2L, 0L, 1L, 2L, 0L, 0L, 2L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, \n",
      "    1L, 1L, 0L, 0L, 0L, 2L, 0L, 2L, 3L, 0L, 0L, 0L, 1L, 0L, 2L, \n",
      "    3L, 2L, 0L, 0L, 2L, 0L, 1L, 0L, 3L, 0L, 1L, 0L, 1L, 3L, 0L, \n",
      "    1L, 5L, 1L, 2L, 3L, 1L, 0L, 3L, 4L, 1L, 0L, 0L, 0L, 1L, 0L, \n",
      "    4L, 0L, 2L, 0L, 0L, 2L, 1L, 0L, 0L, 0L, 0L, 3L, 0L, 0L, 2L, \n",
      "    3L, 1L, 3L, 0L, 1L, 0L, 3L, 1L, 2L, 0L, 0L, 0L, 0L, 1L, 0L, \n",
      "    0L, 1L, 0L, 0L, 2L, 2L, 1L, 0L, 1L, 1L, 1L, 5L, 0L, 2L, 0L, \n",
      "    2L, 5L, 2L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 2L, 1L, 0L, 3L, 0L, \n",
      "    2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 3L, 2L, 1L, \n",
      "    2L, 1L, 2L, 5L, 3L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 3L, 0L, 1L, \n",
      "    0L, 3L, 1L, 5L, 1L, 3L, 1L, 0L, 0L, 1L, 2L, 2L, 1L, 3L, 3L, \n",
      "    3L, 0L, 3L, 0L, 2L, 0L, 0L, 0L, 1L, 2L, 2L, 3L, 2L, 1L, 0L, \n",
      "    2L, 4L, 1L, 0L, 0L, 1L, 2L, 3L, 2L, 0L, 3L, 1L, 1L, 1L, 0L, \n",
      "    1L, 0L, 0L, 2L, 1L, 0L, 0L, 0L, 0L, 3L, 2L, 1L, 0L, 2L, 0L, \n",
      "    0L, 0L, 0L, 1L, 2L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 3L, 0L, 0L, \n",
      "    0L, 0L, 0L, 1L, 0L, 1L, 1L, 3L, 4L, 1L, 2L, 0L, 1L, 1L, 1L, \n",
      "    0L, 0L, 2L, 0L, 1L, 1L, 0L, 0L, 3L, 2L, 1L, 1L, 1L, 2L, 5L, \n",
      "    0L, 0L, 1L, 0L, 0L, 0L, 3L, 0L, 4L, 4L, 2L, 0L, 0L, 1L, 2L, \n",
      "    3L, 1L, 0L, 0L, 0L, 0L, 2L, 1L, 3L, 1L, 3L, 3L, 3L, 0L, 1L, \n",
      "    5L, 2L, 1L, 3L, 0L, 2L, 3L, 1L, 1L, 0L, 0L, 2L, 1L, 0L, 5L, \n",
      "    2L, 0L, 0L, 0L, 3L, 1L, 0L, 0L, 0L, 1L, 3L, 0L, 2L, 2L, 3L, \n",
      "    0L, 0L, 1L, 0L, 0L, 0L, 3L, 1L, 4L, 3L, 0L, 2L, 0L, 0L, 1L, \n",
      "    2L, 1L, 0L, 1L, 0L, 0L, 2L, 2L, 1L, 1L, 2L, 0L, 2L, 2L, 0L, \n",
      "    1L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 2L, 3L, 0L, 1L, 0L, 2L, \n",
      "    1L, 1L, 0L, 0L, 3L, 0L, 0L, 1L, 2L, 2L, 2L, 0L, 1L, 3L, 1L, \n",
      "    2L, 2L, 1L, 1L, 1L, 2L, 0L, 2L, 1L, 0L, 0L, 2L, 1L, 3L, 1L, \n",
      "    2L, 0L, 0L, 1L, 1L, 2L, 2L, 0L, 0L, 3L, 0L, 3L, 0L, 2L, 0L, \n",
      "    0L, 0L, 3L, 1L, 2L, 2L, 3L, 0L, 0L, 5L, 3L, 4L, 0L, 1L, 0L, \n",
      "    0L, 0L, 4L, 0L, 0L, 3L, 1L, 3L, 0L, 0L, 1L, 1L, 1L, 2L, 0L, \n",
      "    0L, 0L, 0L, 3L, 1L, 0L, 5L, 1L, 0L, 0L, 0L, 0L, 1L, 2L, 0L, \n",
      "    2L, 0L, 1L, 1L, 0L, 0L, 1L, 2L, 1L, 2L, 0L, 0L, 3L, 0L, 1L, \n",
      "    0L, 2L, 2L, 1L, 0L, 3L, 1L, 0L, 2L, 0L, 0L, 4L, 0L, 2L, 1L, \n",
      "    0L, 1L, 2L, 3L, 1L, 0L, 0L, 4L, 2L, 3L, 0L, 0L, 2L, 1L, 0L, \n",
      "    0L, 1L, 2L, 2L, 2L, 0L, 3L, 3L, 0L, 0L, 0L, 0L), smoker = c(\"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"yes\", \"yes\", \"no\", \"yes\", \"no\", \"yes\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"yes\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \n",
      "    \"no\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \n",
      "    \"yes\", \"yes\", \"yes\", \"no\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"yes\", \"yes\", \n",
      "    \"no\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \n",
      "    \"yes\", \"yes\", \"no\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \n",
      "    \"no\", \"yes\", \"no\", \"no\", \"no\", \"yes\", \"yes\", \"yes\", \"no\", \n",
      "    \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"yes\", \n",
      "    \"no\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"yes\", \"yes\", \n",
      "    \"no\", \"no\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"yes\", \"yes\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"yes\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"yes\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"yes\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"yes\", \"yes\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"yes\", \"no\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"yes\", \"no\", \n",
      "    \"yes\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"yes\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \"yes\", \n",
      "    \"yes\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \"yes\", \"yes\", \"no\", \n",
      "    \"yes\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"yes\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"yes\", \"yes\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"yes\", \"yes\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"yes\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"yes\", \"no\", \"yes\", \n",
      "    \"no\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"yes\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"yes\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"yes\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \n",
      "    \"yes\", \"no\", \"no\", \"yes\", \"yes\", \"no\", \"yes\", \"no\", \"no\", \n",
      "    \"no\", \"yes\", \"no\", \"no\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"yes\", \"yes\", \"no\", \"yes\", \"yes\", \"no\", \n",
      "    \"yes\", \"yes\", \"yes\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"yes\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"yes\", \"no\", \"yes\", \"no\", \n",
      "    \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \"no\", \n",
      "    \"no\", \"no\", \"yes\"), region = c(\"southwest\", \"southeast\", \n",
      "    \"southeast\", \"northwest\", \"northwest\", \"southeast\", \"southeast\", \n",
      "    \"northwest\", \"northeast\", \"northwest\", \"northeast\", \"southeast\", \n",
      "    \"southwest\", \"southeast\", \"southeast\", \"southwest\", \"northeast\", \n",
      "    \"northeast\", \"southwest\", \"southwest\", \"northeast\", \"southwest\", \n",
      "    \"southeast\", \"northeast\", \"northwest\", \"southeast\", \"northeast\", \n",
      "    \"northwest\", \"northwest\", \"southwest\", \"southwest\", \"northeast\", \n",
      "    \"southwest\", \"northwest\", \"southwest\", \"northwest\", \"northwest\", \n",
      "    \"southwest\", \"northeast\", \"southwest\", \"northeast\", \"southeast\", \n",
      "    \"southeast\", \"southeast\", \"northeast\", \"southwest\", \"northeast\", \n",
      "    \"northwest\", \"southeast\", \"southeast\", \"northeast\", \"northwest\", \n",
      "    \"southwest\", \"southeast\", \"northwest\", \"northwest\", \"northeast\", \n",
      "    \"southeast\", \"southeast\", \"northwest\", \"northeast\", \"southeast\", \n",
      "    \"northwest\", \"northwest\", \"northwest\", \"southwest\", \"southwest\", \n",
      "    \"northwest\", \"southeast\", \"southeast\", \"southeast\", \"northeast\", \n",
      "    \"southwest\", \"southeast\", \"southwest\", \"northwest\", \"southeast\", \n",
      "    \"southeast\", \"northeast\", \"northwest\", \"northeast\", \"northeast\", \n",
      "    \"southeast\", \"northwest\", \"southwest\", \"northwest\", \"northwest\", \n",
      "    \"southwest\", \"northwest\", \"northwest\", \"southeast\", \"northwest\", \n",
      "    \"northeast\", \"northwest\", \"southwest\", \"southeast\", \"southwest\", \n",
      "    \"southeast\", \"northeast\", \"southwest\", \"southwest\", \"northeast\", \n",
      "    \"northeast\", \"southeast\", \"southwest\", \"northwest\", \"southwest\", \n",
      "    \"northwest\", \"southeast\", \"southeast\", \"northwest\", \"southwest\", \n",
      "    \"southwest\", \"northwest\", \"northeast\", \"northeast\", \"southeast\", \n",
      "    \"southeast\", \"southeast\", \"northwest\", \"southwest\", \"northeast\", \n",
      "    \"northwest\", \"northeast\", \"northwest\", \"northeast\", \"southwest\", \n",
      "    \"southwest\", \"northwest\", \"southwest\", \"northeast\", \"northeast\", \n",
      "    \"southwest\", \"northwest\", \"northeast\", \"southeast\", \"southwest\", \n",
      "    \"northwest\", \"southeast\", \"southwest\", \"northeast\", \"northeast\", \n",
      "    \"southeast\", \"northwest\", \"northwest\", \"southeast\", \"northwest\", \n",
      "    \"southeast\", \"northwest\", \"southwest\", \"northwest\", \"southeast\", \n",
      "    \"northeast\", \"northeast\", \"northeast\", \"northwest\", \"southeast\", \n",
      "    \"northeast\", \"southeast\", \"southeast\", \"northwest\", \"southeast\", \n",
      "    \"southwest\", \"southwest\", \"northwest\", \"northeast\", \"southwest\", \n",
      "    \"northwest\", \"northwest\", \"northeast\", \"southeast\", \"southwest\", \n",
      "    \"northeast\", \"southwest\", \"northwest\", \"southwest\", \"northwest\", \n",
      "    \"southwest\", \"southwest\", \"northeast\", \"northwest\", \"southeast\", \n",
      "    \"northeast\", \"northwest\", \"southeast\", \"northeast\", \"southeast\", \n",
      "    \"southwest\", \"southwest\", \"northwest\", \"southeast\", \"southwest\", \n",
      "    \"southeast\", \"northwest\", \"southeast\", \"northwest\", \"southwest\", \n",
      "    \"southeast\", \"northwest\", \"northeast\", \"northwest\", \"southeast\", \n",
      "    \"northwest\", \"southeast\", \"southwest\", \"northeast\", \"southeast\", \n",
      "    \"northeast\", \"southwest\", \"northeast\", \"southwest\", \"northwest\", \n",
      "    \"northwest\", \"southeast\", \"southwest\", \"southwest\", \"northwest\", \n",
      "    \"southeast\", \"southeast\", \"southeast\", \"southwest\", \"northeast\", \n",
      "    \"southwest\", \"southwest\", \"southeast\", \"southeast\", \"southeast\", \n",
      "    \"southeast\", \"northeast\", \"northeast\", \"northwest\", \"southeast\", \n",
      "    \"southwest\", \"southwest\", \"northwest\", \"southeast\", \"southeast\", \n",
      "    \"southeast\", \"northwest\", \"southeast\", \"northeast\", \"northeast\", \n",
      "    \"southwest\", \"southwest\", \"northeast\", \"northwest\", \"southeast\", \n",
      "    \"southeast\", \"southwest\", \"northeast\", \"northeast\", \"southwest\", \n",
      "    \"southeast\", \"southwest\", \"northeast\", \"northeast\", \"northwest\", \n",
      "    \"southeast\", \"northwest\", \"northwest\", \"southwest\", \"southeast\", \n",
      "    \"northeast\", \"northwest\", \"southeast\", \"southeast\", \"southeast\", \n",
      "    \"northeast\", \"southwest\", \"northeast\", \"southeast\", \"southwest\", \n",
      "    \"northwest\", \"northeast\", \"northwest\", \"northeast\", \"northwest\", \n",
      "    \"southwest\", \"southeast\", \"southeast\", \"northeast\", \"northeast\", \n",
      "    \"northeast\", \"northeast\", \"southwest\", \"southeast\", \"northeast\", \n",
      "    \"northwest\", \"northeast\", \"southeast\", \"southwest\", \"northeast\", \n",
      "    \"southeast\", \"southeast\", \"southwest\", \"northeast\", \"southwest\", \n",
      "    \"southeast\", \"northwest\", \"northwest\", \"northeast\", \"northeast\", \n",
      "    \"southeast\", \"southeast\", \"southwest\", \"northwest\", \"southwest\", \n",
      "    \"southeast\", \"northeast\", \"northwest\", \"southwest\", \"southwest\", \n",
      "    \"southeast\", \"southeast\", \"southwest\", \"northeast\", \"northwest\", \n",
      "    \"northeast\", \"northwest\", \"northeast\", \"northwest\", \"northeast\", \n",
      "    \"southwest\", \"northeast\", \"southwest\", \"northeast\", \"southeast\", \n",
      "    \"northwest\", \"southwest\", \"southwest\", \"northeast\", \"northwest\", \n",
      "    \"northwest\", \"northeast\", \"northeast\", \"southwest\", \"southeast\", \n",
      "    \"northwest\", \"northeast\", \"southeast\", \"southwest\", \"northwest\", \n",
      "    \"northeast\", \"northeast\", \"southeast\", \"southeast\", \"southeast\", \n",
      "    \"northeast\", \"southeast\", \"northwest\", \"northwest\", \"southwest\", \n",
      "    \"southwest\", \"northeast\", \"southeast\", \"southwest\", \"southeast\", \n",
      "    \"northwest\", \"southeast\", \"southeast\", \"northeast\", \"southwest\", \n",
      "    \"southwest\", \"southwest\", \"southeast\", \"northeast\", \"northeast\", \n",
      "    \"northwest\", \"northwest\", \"northeast\", \"northwest\", \"northeast\", \n",
      "    \"northeast\", \"southwest\", \"southeast\", \"northwest\", \"northeast\", \n",
      "    \"southeast\", \"northwest\", \"southeast\", \"northeast\", \"northeast\", \n",
      "    \"southeast\", \"southeast\", \"northeast\", \"southwest\", \"southeast\", \n",
      "    \"northwest\", \"northwest\", \"northwest\", \"northeast\", \"northwest\", \n",
      "    \"northeast\", \"northeast\", \"northeast\", \"northwest\", \"southwest\", \n",
      "    \"southeast\", \"southwest\", \"southeast\", \"southwest\", \"southeast\", \n",
      "    \"northwest\", \"northwest\", \"southwest\", \"northeast\", \"southeast\", \n",
      "    \"southwest\", \"southeast\", \"southeast\", \"northwest\", \"northeast\", \n",
      "    \"northeast\", \"southwest\", \"northwest\", \"southeast\", \"southeast\", \n",
      "    \"southwest\", \"southeast\", \"northwest\", \"southeast\", \"southeast\", \n",
      "    \"northeast\", \"northeast\", \"southwest\", \"southeast\", \"northeast\", \n",
      "    \"northeast\", \"northeast\", \"northwest\", \"southwest\", \"northwest\", \n",
      "    \"southwest\", \"southwest\", \"northwest\", \"southeast\", \"northeast\", \n",
      "    \"southwest\", \"southeast\", \"northeast\", \"northwest\", \"southwest\", \n",
      "    \"southeast\", \"southeast\", \"northwest\", \"southwest\", \"northeast\", \n",
      "    \"northwest\", \"southwest\", \"southwest\", \"southwest\", \"northwest\", \n",
      "    \"southwest\", \"northwest\", \"southeast\", \"southwest\", \"southeast\", \n",
      "    \"northwest\", \"southwest\", \"southeast\", \"southeast\", \"southwest\", \n",
      "    \"northeast\", \"northeast\", \"northwest\", \"southeast\", \"southwest\", \n",
      "    \"northwest\", \"northeast\", \"southeast\", \"southeast\", \"northeast\", \n",
      "    \"southwest\", \"northeast\", \"southwest\", \"northwest\", \"northeast\", \n",
      "    \"northwest\", \"southeast\", \"southeast\", \"northwest\", \"southeast\", \n",
      "    \"southeast\", \"southwest\", \"southwest\", \"northeast\", \"northwest\", \n",
      "    \"southwest\", \"southeast\", \"northwest\", \"southwest\", \"southeast\", \n",
      "    \"northeast\", \"southwest\", \"southwest\", \"northeast\", \"southwest\", \n",
      "    \"southwest\", \"southeast\", \"southwest\", \"southwest\", \"northeast\", \n",
      "    \"southeast\", \"southeast\", \"southeast\", \"northwest\", \"northwest\", \n",
      "    \"northwest\", \"northeast\", \"southwest\", \"northeast\", \"southeast\", \n",
      "    \"northeast\", \"southwest\", \"southwest\", \"southwest\", \"southeast\", \n",
      "    \"northwest\", \"southwest\", \"northeast\", \"northeast\", \"southeast\", \n",
      "    \"northeast\", \"southeast\", \"southeast\", \"southeast\", \"northwest\", \n",
      "    \"southwest\", \"northeast\", \"northeast\", \"southeast\", \"northeast\", \n",
      "    \"southeast\", \"southeast\", \"southeast\", \"northeast\", \"southwest\", \n",
      "    \"southwest\", \"southeast\", \"southeast\", \"southwest\", \"southeast\", \n",
      "    \"southeast\", \"southeast\", \"northwest\", \"northwest\", \"northeast\", \n",
      "    \"southwest\", \"northeast\", \"southeast\", \"southwest\", \"southeast\", \n",
      "    \"southwest\", \"northwest\", \"northeast\", \"southwest\", \"northeast\", \n",
      "    \"southeast\", \"northwest\", \"northwest\", \"northwest\", \"northeast\", \n",
      "    \"southwest\", \"southeast\", \"southeast\", \"northwest\", \"northwest\", \n",
      "    \"northwest\", \"southwest\", \"northwest\", \"southwest\", \"southeast\", \n",
      "    \"southeast\", \"northeast\", \"northeast\", \"northwest\", \"southeast\", \n",
      "    \"northeast\", \"southwest\", \"northeast\", \"northeast\", \"northwest\", \n",
      "    \"southeast\", \"southeast\", \"southwest\", \"southeast\", \"northeast\", \n",
      "    \"northwest\", \"northeast\", \"southeast\", \"southwest\", \"northwest\", \n",
      "    \"southeast\", \"northeast\", \"southeast\", \"northeast\", \"southeast\", \n",
      "    \"northeast\", \"southwest\", \"northwest\", \"southeast\", \"northwest\", \n",
      "    \"southwest\", \"southeast\", \"northwest\", \"southeast\", \"northeast\", \n",
      "    \"northwest\", \"northeast\", \"southwest\", \"southeast\", \"southwest\", \n",
      "    \"northeast\", \"northeast\", \"southeast\", \"southeast\", \"northeast\", \n",
      "    \"southwest\", \"southeast\", \"southwest\", \"southwest\", \"southwest\", \n",
      "    \"southwest\", \"northeast\", \"northwest\", \"northwest\", \"northeast\", \n",
      "    \"southeast\", \"southwest\", \"northwest\", \"southwest\", \"southwest\", \n",
      "    \"southeast\", \"northeast\", \"southwest\", \"northeast\", \"northwest\", \n",
      "    \"northeast\", \"northeast\", \"southeast\", \"southwest\", \"northwest\", \n",
      "    \"northeast\", \"northwest\", \"southeast\", \"northeast\", \"northwest\", \n",
      "    \"northeast\", \"northeast\", \"northeast\", \"southeast\", \"southeast\", \n",
      "    \"southeast\", \"southeast\", \"southeast\", \"southeast\", \"southwest\", \n",
      "    \"northwest\", \"northeast\", \"northeast\", \"southeast\", \"southeast\", \n",
      "    \"northeast\", \"southeast\", \"southeast\", \"southeast\", \"southwest\", \n",
      "    \"northwest\", \"northeast\", \"southeast\", \"southeast\", \"northeast\", \n",
      "    \"southeast\", \"southeast\", \"southeast\", \"northwest\", \"southeast\", \n",
      "    \"northwest\", \"southwest\", \"northwest\", \"southwest\", \"southwest\", \n",
      "    \"southwest\", \"northwest\", \"southwest\", \"northeast\", \"northeast\", \n",
      "    \"southeast\", \"southwest\", \"southeast\", \"northeast\", \"southwest\", \n",
      "    \"northwest\", \"northwest\", \"southwest\", \"northwest\", \"northeast\", \n",
      "    \"southeast\", \"northwest\", \"southeast\", \"southeast\", \"northeast\", \n",
      "    \"southeast\", \"northwest\", \"northwest\", \"southwest\", \"southeast\", \n",
      "    \"northwest\", \"northeast\", \"northeast\", \"southeast\", \"southeast\", \n",
      "    \"northwest\", \"northeast\", \"southwest\", \"southwest\", \"northwest\", \n",
      "    \"northwest\", \"northwest\", \"northwest\", \"northeast\", \"southwest\", \n",
      "    \"southwest\", \"southwest\", \"northeast\", \"southeast\", \"northwest\", \n",
      "    \"northeast\", \"northeast\", \"southeast\", \"southeast\", \"southwest\", \n",
      "    \"southwest\", \"northeast\", \"southwest\", \"northwest\", \"southeast\", \n",
      "    \"southwest\", \"northeast\", \"southwest\", \"northeast\", \"southeast\", \n",
      "    \"northeast\", \"southeast\", \"northwest\", \"northwest\", \"southwest\", \n",
      "    \"northwest\", \"southwest\", \"northwest\", \"southeast\", \"northwest\", \n",
      "    \"northwest\", \"southeast\", \"northeast\", \"northeast\", \"northeast\", \n",
      "    \"southeast\", \"northeast\", \"southeast\", \"northeast\", \"southwest\", \n",
      "    \"southwest\", \"northeast\", \"northeast\", \"northwest\", \"southwest\", \n",
      "    \"southwest\", \"southwest\", \"northwest\", \"southwest\", \"southwest\", \n",
      "    \"northeast\", \"northwest\", \"northwest\", \"southeast\", \"northwest\", \n",
      "    \"northeast\", \"southeast\", \"northwest\", \"southwest\", \"southeast\", \n",
      "    \"southeast\", \"southwest\", \"southeast\", \"southwest\", \"northeast\", \n",
      "    \"northwest\", \"northeast\", \"southeast\", \"southeast\", \"southwest\", \n",
      "    \"northeast\", \"southeast\", \"northwest\", \"northwest\", \"southeast\", \n",
      "    \"northeast\", \"southwest\", \"northeast\", \"southeast\", \"southeast\", \n",
      "    \"southwest\", \"southeast\", \"southeast\", \"northwest\", \"northwest\", \n",
      "    \"northwest\", \"southeast\", \"northeast\", \"southwest\", \"northwest\", \n",
      "    \"southeast\", \"northeast\", \"southeast\", \"southeast\", \"northwest\", \n",
      "    \"southwest\", \"northeast\", \"northwest\", \"southwest\", \"northwest\", \n",
      "    \"southeast\", \"southeast\", \"northwest\", \"northeast\", \"southeast\", \n",
      "    \"northeast\", \"northeast\", \"northwest\", \"southwest\", \"northwest\", \n",
      "    \"northwest\", \"northwest\", \"northwest\", \"southeast\", \"southwest\", \n",
      "    \"northeast\", \"northeast\", \"northwest\", \"southwest\", \"northeast\", \n",
      "    \"southeast\", \"southeast\", \"northeast\", \"southeast\", \"southwest\", \n",
      "    \"southeast\", \"southwest\", \"northwest\", \"northeast\", \"northwest\", \n",
      "    \"northeast\", \"northeast\", \"northeast\", \"southwest\", \"southeast\", \n",
      "    \"northwest\", \"southeast\", \"southwest\", \"southwest\", \"southwest\", \n",
      "    \"northwest\", \"northeast\", \"southwest\", \"southwest\", \"southeast\", \n",
      "    \"southwest\", \"northeast\", \"southwest\", \"southwest\", \"southeast\", \n",
      "    \"southeast\", \"southwest\", \"northeast\", \"northwest\", \"southwest\", \n",
      "    \"southeast\", \"southwest\", \"southwest\", \"southwest\", \"northwest\", \n",
      "    \"northeast\", \"northeast\", \"northwest\", \"southeast\", \"northeast\", \n",
      "    \"northwest\", \"southwest\", \"northwest\", \"northwest\", \"southeast\", \n",
      "    \"northeast\", \"southeast\", \"northeast\", \"southwest\", \"northeast\", \n",
      "    \"northwest\", \"southeast\", \"northwest\", \"northeast\", \"southeast\", \n",
      "    \"northeast\", \"southeast\", \"southwest\", \"northeast\", \"northeast\", \n",
      "    \"southeast\", \"southwest\", \"southwest\", \"northwest\", \"northeast\", \n",
      "    \"northwest\", \"southwest\", \"northwest\", \"southeast\", \"northwest\", \n",
      "    \"northeast\", \"southwest\", \"southeast\", \"southwest\", \"southwest\", \n",
      "    \"southwest\", \"northwest\", \"southwest\", \"northeast\", \"southwest\", \n",
      "    \"southwest\", \"southeast\", \"southeast\", \"southeast\", \"southwest\", \n",
      "    \"southwest\", \"southwest\", \"southeast\", \"southwest\", \"northeast\", \n",
      "    \"northwest\", \"southeast\", \"southeast\", \"southeast\", \"southeast\", \n",
      "    \"northeast\", \"northwest\", \"southeast\", \"southwest\", \"southwest\", \n",
      "    \"northeast\", \"northwest\", \"southwest\", \"northeast\", \"southeast\", \n",
      "    \"northwest\", \"southwest\", \"northwest\", \"southeast\", \"southeast\", \n",
      "    \"northwest\", \"northeast\", \"northwest\", \"northwest\", \"southwest\", \n",
      "    \"southeast\", \"northeast\", \"northwest\", \"southwest\", \"northwest\", \n",
      "    \"northwest\", \"northeast\", \"southeast\", \"southeast\", \"northeast\", \n",
      "    \"northwest\", \"southwest\", \"southeast\", \"northeast\", \"southeast\", \n",
      "    \"southeast\", \"northeast\", \"southeast\", \"northeast\", \"northeast\", \n",
      "    \"southwest\", \"northeast\", \"northeast\", \"southwest\", \"northwest\", \n",
      "    \"northwest\", \"northeast\", \"northeast\", \"southwest\", \"northeast\", \n",
      "    \"southwest\", \"southeast\", \"northwest\", \"northeast\", \"southwest\", \n",
      "    \"southeast\", \"northeast\", \"northwest\", \"northwest\", \"southwest\", \n",
      "    \"southwest\", \"southwest\", \"northeast\", \"northwest\", \"northeast\", \n",
      "    \"northwest\", \"northeast\", \"northeast\", \"southwest\", \"southeast\", \n",
      "    \"southeast\", \"northwest\", \"southwest\", \"northwest\", \"northwest\", \n",
      "    \"southwest\", \"northwest\", \"northwest\", \"southwest\", \"southeast\", \n",
      "    \"southeast\", \"southeast\", \"southeast\", \"southwest\", \"northwest\", \n",
      "    \"northwest\", \"southwest\", \"northeast\", \"northwest\", \"southeast\", \n",
      "    \"northeast\", \"northeast\", \"northwest\", \"southwest\", \"southeast\", \n",
      "    \"northwest\", \"northeast\", \"northwest\", \"northwest\", \"northeast\", \n",
      "    \"northeast\", \"southwest\", \"northeast\", \"northwest\", \"northeast\", \n",
      "    \"southeast\", \"northwest\", \"southwest\", \"northwest\", \"northeast\", \n",
      "    \"northeast\", \"southwest\", \"northwest\", \"northwest\", \"southwest\", \n",
      "    \"southeast\", \"southeast\", \"northwest\", \"southeast\", \"southeast\", \n",
      "    \"southeast\", \"northwest\", \"southwest\", \"southwest\", \"southeast\", \n",
      "    \"northeast\", \"northwest\", \"southeast\", \"southeast\", \"northeast\", \n",
      "    \"northwest\", \"northeast\", \"northeast\", \"southeast\", \"southwest\", \n",
      "    \"northeast\", \"southeast\", \"southeast\", \"southeast\", \"northwest\", \n",
      "    \"northwest\", \"southwest\", \"northwest\", \"southwest\", \"northeast\", \n",
      "    \"northwest\", \"southeast\", \"southwest\", \"southeast\", \"northeast\", \n",
      "    \"southwest\", \"northwest\", \"southwest\", \"northeast\", \"northeast\", \n",
      "    \"southeast\", \"northeast\", \"southeast\", \"northeast\", \"southwest\", \n",
      "    \"southeast\", \"southeast\", \"southwest\", \"southeast\", \"northwest\", \n",
      "    \"northwest\", \"southwest\", \"southeast\", \"northeast\", \"southeast\", \n",
      "    \"southeast\", \"northwest\", \"northeast\", \"southeast\", \"northeast\", \n",
      "    \"southeast\", \"southeast\", \"northwest\", \"southwest\", \"southeast\", \n",
      "    \"northwest\", \"northeast\", \"northeast\", \"northwest\", \"southwest\", \n",
      "    \"southeast\", \"southwest\", \"southwest\", \"southeast\", \"southwest\", \n",
      "    \"northeast\", \"northwest\", \"northwest\", \"northwest\", \"southwest\", \n",
      "    \"northwest\", \"southeast\", \"northwest\", \"southeast\", \"southwest\", \n",
      "    \"southeast\", \"southeast\", \"southwest\", \"northwest\", \"southwest\", \n",
      "    \"northwest\", \"southwest\", \"southwest\", \"northeast\", \"northwest\", \n",
      "    \"southeast\", \"northwest\", \"northwest\", \"northeast\", \"southeast\", \n",
      "    \"northwest\", \"northeast\", \"southwest\", \"northwest\", \"southeast\", \n",
      "    \"southeast\", \"northeast\", \"northwest\", \"northeast\", \"southeast\", \n",
      "    \"southwest\", \"southwest\", \"northwest\", \"northeast\", \"southwest\", \n",
      "    \"southeast\", \"northwest\", \"northwest\", \"southwest\", \"northwest\", \n",
      "    \"southwest\", \"northeast\", \"southeast\", \"northeast\", \"northwest\", \n",
      "    \"southwest\", \"northeast\", \"southeast\", \"northeast\", \"northwest\", \n",
      "    \"northwest\", \"northeast\", \"southwest\", \"northwest\", \"northeast\", \n",
      "    \"northeast\", \"northwest\", \"northwest\", \"northwest\", \"northwest\", \n",
      "    \"southeast\", \"northwest\", \"southwest\", \"northwest\", \"northwest\", \n",
      "    \"northwest\", \"northeast\", \"southeast\", \"northwest\", \"southwest\", \n",
      "    \"southwest\", \"northeast\", \"southwest\", \"northwest\", \"southeast\", \n",
      "    \"northeast\", \"southwest\", \"northwest\", \"northeast\", \"southeast\", \n",
      "    \"southeast\", \"southwest\", \"northwest\", \"northeast\", \"southeast\", \n",
      "    \"southeast\", \"southeast\", \"northeast\", \"southeast\", \"northeast\", \n",
      "    \"southeast\", \"southeast\", \"northeast\", \"northwest\", \"southwest\", \n",
      "    \"northwest\", \"southwest\", \"southeast\", \"northwest\", \"northeast\", \n",
      "    \"northwest\", \"northeast\", \"southeast\", \"southeast\", \"southeast\", \n",
      "    \"northwest\", \"southeast\", \"southeast\", \"southwest\", \"southwest\", \n",
      "    \"southwest\", \"southeast\", \"northeast\", \"northeast\", \"southwest\", \n",
      "    \"southwest\", \"southwest\", \"southeast\", \"southwest\", \"northwest\", \n",
      "    \"northwest\", \"northwest\", \"northeast\", \"northeast\", \"southwest\", \n",
      "    \"southeast\", \"southwest\", \"northeast\", \"southeast\", \"southwest\", \n",
      "    \"northeast\", \"southwest\", \"southwest\", \"northwest\", \"northwest\", \n",
      "    \"southeast\", \"southeast\", \"southeast\", \"southwest\", \"northeast\", \n",
      "    \"northwest\", \"northeast\", \"northwest\", \"southeast\", \"northwest\", \n",
      "    \"northeast\", \"southeast\", \"southwest\", \"northeast\", \"northeast\", \n",
      "    \"southwest\", \"southwest\", \"southeast\", \"northeast\", \"southwest\", \n",
      "    \"southeast\", \"northwest\", \"northeast\", \"southwest\", \"northeast\", \n",
      "    \"southeast\", \"northwest\", \"northwest\", \"southeast\", \"northwest\", \n",
      "    \"southwest\", \"southwest\", \"northeast\", \"southeast\", \"northeast\", \n",
      "    \"northwest\", \"southwest\", \"southwest\", \"northwest\", \"northwest\", \n",
      "    \"southwest\", \"southwest\", \"northwest\", \"northeast\", \"southwest\", \n",
      "    \"southeast\", \"northeast\", \"northwest\", \"northwest\", \"northeast\", \n",
      "    \"southeast\", \"southeast\", \"northwest\", \"northeast\", \"northeast\", \n",
      "    \"southeast\", \"northeast\", \"southwest\", \"southeast\", \"southwest\", \n",
      "    \"southwest\", \"northwest\", \"northeast\", \"southeast\", \"southwest\", \n",
      "    \"northwest\"), charges = c(16884L, 1725L, 4449L, 21984L, 3866L, \n",
      "    3756L, 8240L, 7281L, 6406L, 28923L, 2721L, 27808L, 1826L, \n",
      "    11090L, 39611L, 1837L, 10797L, 2395L, 10602L, 36837L, 13228L, \n",
      "    4149L, 1137L, 37701L, 6203L, 14001L, 14451L, 12268L, 2775L, \n",
      "    38711L, 35585L, 2198L, 4687L, 13770L, 51194L, 1625L, 15612L, \n",
      "    2302L, 39774L, 48173L, 3046L, 4949L, 6272L, 6313L, 6079L, \n",
      "    20630L, 3393L, 3556L, 12629L, 38709L, 2211L, 3579L, 23568L, \n",
      "    37742L, 8059L, 47496L, 13607L, 34303L, 23244L, 5989L, 8606L, \n",
      "    4504L, 30166L, 4133L, 14711L, 1743L, 14235L, 6389L, 5920L, \n",
      "    17663L, 16577L, 6799L, 11741L, 11946L, 7726L, 11356L, 3947L, \n",
      "    1532L, 2755L, 6571L, 4441L, 7935L, 37165L, 11033L, 39836L, \n",
      "    21098L, 43578L, 11073L, 8026L, 11082L, 2026L, 10942L, 30184L, \n",
      "    5729L, 47291L, 3766L, 12105L, 10226L, 22412L, 15820L, 6186L, \n",
      "    3645L, 21344L, 30942L, 5003L, 17560L, 2331L, 3877L, 2867L, \n",
      "    47055L, 10825L, 11881L, 4646L, 2404L, 11488L, 30259L, 11381L, \n",
      "    19107L, 8601L, 6686L, 7740L, 1705L, 2257L, 39556L, 10115L, \n",
      "    3385L, 17081L, 9634L, 32734L, 6082L, 12815L, 13616L, 11163L, \n",
      "    1632L, 2457L, 2155L, 1261L, 2045L, 27322L, 2166L, 27375L, \n",
      "    3490L, 18972L, 18157L, 20745L, 5138L, 40720L, 9877L, 10959L, \n",
      "    1842L, 5125L, 7789L, 6334L, 19964L, 7077L, 6948L, 21223L, \n",
      "    15518L, 36950L, 19749L, 21348L, 36149L, 10450L, 5152L, 5028L, \n",
      "    10407L, 4830L, 6128L, 2719L, 4827L, 13405L, 8116L, 1694L, \n",
      "    5246L, 2855L, 48824L, 6455L, 10436L, 8823L, 8538L, 11735L, \n",
      "    1631L, 4005L, 7419L, 7731L, 43753L, 3981L, 5325L, 6775L, \n",
      "    4922L, 12557L, 4883L, 2137L, 12044L, 1137L, 1639L, 5649L, \n",
      "    8516L, 9644L, 14901L, 2130L, 8871L, 13012L, 37133L, 7147L, \n",
      "    4337L, 11743L, 20984L, 13880L, 6610L, 1980L, 8162L, 3537L, \n",
      "    5002L, 8520L, 7371L, 10355L, 2483L, 3392L, 25081L, 5012L, \n",
      "    10564L, 5253L, 34779L, 19515L, 11987L, 2689L, 24227L, 7358L, \n",
      "    9225L, 7443L, 14001L, 1727L, 12333L, 6710L, 19444L, 1615L, \n",
      "    4463L, 17352L, 7152L, 38511L, 5354L, 35160L, 7196L, 29523L, \n",
      "    24476L, 12648L, 1986L, 1832L, 4040L, 12829L, 47305L, 44260L, \n",
      "    4260L, 41097L, 13047L, 43921L, 5400L, 11520L, 33750L, 11837L, \n",
      "    17085L, 24869L, 36219L, 20462L, 46151L, 17179L, 14590L, 7441L, \n",
      "    9282L, 1719L, 42856L, 7265L, 9617L, 2523L, 9715L, 2803L, \n",
      "    2150L, 12928L, 9855L, 22331L, 48549L, 4237L, 11879L, 9625L, \n",
      "    7742L, 9432L, 14256L, 47896L, 25992L, 3172L, 20277L, 42112L, \n",
      "    2156L, 3906L, 1704L, 16297L, 21978L, 38746L, 9249L, 6746L, \n",
      "    24873L, 12265L, 4349L, 12646L, 19442L, 20177L, 4151L, 11944L, \n",
      "    7749L, 8444L, 1737L, 42124L, 8124L, 34838L, 9722L, 8835L, \n",
      "    10435L, 7421L, 4667L, 4894L, 24671L, 35491L, 11566L, 2866L, \n",
      "    6600L, 3561L, 42760L, 47928L, 9144L, 48517L, 24393L, 13429L, \n",
      "    11658L, 19144L, 13822L, 12142L, 13937L, 41919L, 8232L, 18955L, \n",
      "    13352L, 13217L, 13981L, 10977L, 6184L, 4889L, 8334L, 5478L, \n",
      "    1635L, 11830L, 8932L, 3554L, 12404L, 14133L, 24603L, 8944L, \n",
      "    9620L, 1837L, 1607L, 10043L, 4751L, 13844L, 2597L, 3180L, \n",
      "    9778L, 13430L, 8017L, 8116L, 3481L, 13415L, 12029L, 7639L, \n",
      "    36085L, 1391L, 18033L, 21659L, 38126L, 16455L, 27000L, 15006L, \n",
      "    42303L, 20781L, 5846L, 8302L, 1261L, 11856L, 30284L, 3176L, \n",
      "    4618L, 10736L, 2138L, 8964L, 9290L, 9411L, 7526L, 8522L, \n",
      "    16586L, 14988L, 1631L, 9264L, 8083L, 14692L, 10269L, 3260L, \n",
      "    11396L, 4185L, 8539L, 6652L, 4074L, 1621L, 19594L, 14455L, \n",
      "    5080L, 2134L, 7345L, 9140L, 18608L, 14418L, 28950L, 46889L, \n",
      "    46599L, 39125L, 2727L, 8968L, 9788L, 6555L, 7323L, 3167L, \n",
      "    18804L, 23082L, 4906L, 5969L, 12638L, 4243L, 13919L, 2254L, \n",
      "    5926L, 12592L, 2897L, 4738L, 37079L, 1149L, 28287L, 26109L, \n",
      "    7345L, 12730L, 11454L, 5910L, 4762L, 7512L, 4032L, 1969L, \n",
      "    1769L, 4686L, 21797L, 11881L, 11840L, 10601L, 7682L, 10381L, \n",
      "    22144L, 15230L, 11165L, 1632L, 19521L, 13224L, 12643L, 23288L, \n",
      "    2201L, 2497L, 2203L, 1744L, 20878L, 25382L, 28868L, 35147L, \n",
      "    2534L, 1534L, 1824L, 15555L, 9304L, 1622L, 9880L, 9563L, \n",
      "    4347L, 12475L, 1253L, 48885L, 10461L, 1748L, 24513L, 2196L, \n",
      "    12574L, 17942L, 1967L, 4931L, 8027L, 8211L, 13470L, 36197L, \n",
      "    6837L, 22218L, 32548L, 5974L, 6796L, 2643L, 3077L, 3044L, \n",
      "    11455L, 11763L, 2498L, 9361L, 1256L, 21082L, 11362L, 27724L, \n",
      "    8413L, 5240L, 3857L, 25656L, 3994L, 9866L, 5397L, 38245L, \n",
      "    11482L, 24059L, 9861L, 8342L, 1708L, 48675L, 14043L, 12925L, \n",
      "    19214L, 13831L, 6067L, 5972L, 8825L, 8233L, 27346L, 6196L, \n",
      "    3056L, 13887L, 63770L, 10231L, 23807L, 3268L, 11538L, 3213L, \n",
      "    45863L, 13390L, 3972L, 12957L, 11187L, 17878L, 3847L, 8334L, \n",
      "    3935L, 39983L, 1646L, 9193L, 10923L, 2494L, 9058L, 2801L, \n",
      "    2128L, 6373L, 7256L, 11552L, 45702L, 3761L, 2219L, 4753L, \n",
      "    31620L, 13224L, 12222L, 1664L, 58571L, 9724L, 3206L, 12913L, \n",
      "    1639L, 6356L, 17626L, 1242L, 4779L, 3861L, 43943L, 13635L, \n",
      "    5976L, 11842L, 8428L, 2566L, 15359L, 5709L, 8823L, 7640L, \n",
      "    5594L, 7441L, 33471L, 1633L, 9174L, 11070L, 16085L, 17468L, \n",
      "    9283L, 3558L, 25678L, 4435L, 39241L, 8547L, 6571L, 2207L, \n",
      "    6753L, 1880L, 42969L, 11658L, 23306L, 34439L, 10713L, 3659L, \n",
      "    40182L, 9182L, 34617L, 12129L, 3736L, 6748L, 11326L, 11365L, \n",
      "    42983L, 10085L, 1977L, 3366L, 7173L, 9391L, 14410L, 2709L, \n",
      "    24915L, 20149L, 12949L, 6666L, 32787L, 13143L, 4466L, 18806L, \n",
      "    10141L, 6123L, 8252L, 1712L, 12430L, 9800L, 10579L, 8280L, \n",
      "    8527L, 12244L, 24667L, 3410L, 4058L, 26392L, 14394L, 6435L, \n",
      "    22192L, 5148L, 1136L, 27037L, 42560L, 8703L, 40003L, 45710L, \n",
      "    6500L, 4837L, 3943L, 4399L, 6185L, 46200L, 7222L, 12485L, \n",
      "    46130L, 12363L, 10156L, 2585L, 1242L, 40103L, 9863L, 4766L, \n",
      "    11244L, 7729L, 5438L, 26236L, 34806L, 2104L, 8068L, 2362L, \n",
      "    2352L, 3577L, 3201L, 29186L, 40273L, 10976L, 3500L, 2020L, \n",
      "    9541L, 9504L, 5385L, 8930L, 5375L, 44400L, 10264L, 6113L, \n",
      "    5469L, 1727L, 10107L, 8310L, 1984L, 2457L, 12146L, 9566L, \n",
      "    13112L, 10848L, 12231L, 9875L, 11264L, 12979L, 1263L, 10106L, \n",
      "    40932L, 6664L, 16657L, 2217L, 6781L, 19361L, 10065L, 4234L, \n",
      "    9447L, 14007L, 9583L, 40419L, 3484L, 36189L, 44585L, 8604L, \n",
      "    18246L, 43254L, 3757L, 8827L, 9910L, 11737L, 1627L, 8556L, \n",
      "    3062L, 19539L, 1906L, 14210L, 11833L, 17128L, 5031L, 7985L, \n",
      "    23065L, 5428L, 36307L, 3925L, 2416L, 19040L, 3070L, 9095L, \n",
      "    11842L, 8062L, 7050L, 14319L, 6933L, 27941L, 11150L, 12797L, \n",
      "    17748L, 7261L, 10560L, 6986L, 7448L, 5934L, 9869L, 18259L, \n",
      "    1146L, 9386L, 24520L, 4350L, 6414L, 12741L, 1917L, 5209L, \n",
      "    13457L, 5662L, 1252L, 2731L, 21195L, 7209L, 18310L, 4266L, \n",
      "    4719L, 11848L, 17904L, 7046L, 14313L, 2103L, 38792L, 1815L, \n",
      "    7731L, 28476L, 2136L, 1131L, 3309L, 9414L, 6360L, 11013L, \n",
      "    4428L, 5584L, 1877L, 2842L, 3597L, 23401L, 55135L, 7445L, \n",
      "    2680L, 1621L, 8219L, 12523L, 16069L, 43813L, 20773L, 39597L, \n",
      "    6117L, 13393L, 5266L, 4719L, 11743L, 5377L, 7160L, 4402L, \n",
      "    11657L, 6402L, 12622L, 1526L, 12323L, 36021L, 27533L, 10072L, \n",
      "    45008L, 9872L, 2438L, 2974L, 10601L, 37270L, 14119L, 42111L, \n",
      "    11729L, 24106L, 1875L, 40974L, 15817L, 18218L, 10965L, 46113L, \n",
      "    7151L, 12269L, 5458L, 8782L, 6600L, 1141L, 11576L, 13129L, \n",
      "    4391L, 8457L, 3392L, 5966L, 6849L, 8891L, 2690L, 26140L, \n",
      "    6653L, 6282L, 6311L, 3443L, 2789L, 2585L, 46255L, 4877L, \n",
      "    19719L, 27218L, 5272L, 1682L, 11945L, 29330L, 7243L, 10422L, \n",
      "    44202L, 13555L, 13063L, 19798L, 2221L, 1634L, 2117L, 8688L, \n",
      "    48673L, 4661L, 8125L, 12644L, 4564L, 4846L, 7633L, 15170L, \n",
      "    17496L, 2639L, 33732L, 14382L, 7626L, 5257L, 2473L, 21774L, \n",
      "    35069L, 13041L, 5245L, 13451L, 13462L, 5488L, 4320L, 6250L, \n",
      "    25333L, 2913L, 12032L, 13470L, 6289L, 2927L, 6238L, 10096L, \n",
      "    7348L, 4673L, 12233L, 32108L, 8965L, 2304L, 9487L, 1121L, \n",
      "    9549L, 2217L, 1628L, 12982L, 11674L, 7160L, 39047L, 6358L, \n",
      "    19933L, 11534L, 47462L, 4527L, 38998L, 20009L, 3875L, 41999L, \n",
      "    12609L, 41034L, 28468L, 2730L, 3353L, 14474L, 9500L, 26467L, \n",
      "    4746L, 23967L, 7518L, 3279L, 8596L, 10702L, 4992L, 2527L, \n",
      "    1759L, 2322L, 16138L, 7804L, 2902L, 9704L, 4889L, 25517L, \n",
      "    4500L, 19199L, 16796L, 4915L, 7624L, 8410L, 28340L, 4518L, \n",
      "    14571L, 3378L, 7144L, 10118L, 5484L, 16420L, 7986L, 7418L, \n",
      "    13887L, 6551L, 5267L, 17361L, 34472L, 1972L, 21232L, 8627L, \n",
      "    4433L, 4438L, 24915L, 23241L, 9957L, 8269L, 18767L, 36580L, \n",
      "    8765L, 5383L, 12124L, 2709L, 3987L, 12495L, 26018L, 8798L, \n",
      "    35595L, 42211L, 1711L, 8569L, 2020L, 16450L, 21595L, 9850L, \n",
      "    6877L, 21677L, 44423L, 4137L, 13747L, 12950L, 12094L, 37484L, \n",
      "    39725L, 2250L, 22493L, 20234L, 1704L, 33475L, 3161L, 11394L, \n",
      "    21880L, 7325L, 44501L, 3594L, 39727L, 8023L, 14394L, 9288L, \n",
      "    25309L, 3353L, 10594L, 8277L, 17929L, 2480L, 4462L, 1981L, \n",
      "    11554L, 48970L, 6548L, 5708L, 7045L, 8978L, 5757L, 14349L, \n",
      "    10928L, 39871L, 13974L, 1909L, 12096L, 13204L, 4562L, 8551L, \n",
      "    2102L, 34672L, 15161L, 11884L, 4454L, 5855L, 4076L, 15019L, \n",
      "    19023L, 10796L, 11353L, 9748L, 10577L, 41676L, 11286L, 3591L, \n",
      "    33907L, 11299L, 4561L, 44641L, 1674L, 23045L, 3227L, 16776L, \n",
      "    11253L, 3471L, 11363L, 20420L, 10338L, 8988L, 10493L, 2904L, \n",
      "    8605L, 11512L, 41949L, 24180L, 5312L, 2396L, 10807L, 9222L, \n",
      "    36124L, 38282L, 5693L, 34166L, 8347L, 46661L, 18903L, 40904L, \n",
      "    14254L, 10214L, 5836L, 14358L, 1728L, 8582L, 3693L, 20709L, \n",
      "    9991L, 19673L, 11085L, 7623L, 3176L, 3704L, 36898L, 9048L, \n",
      "    7954L, 27117L, 6338L, 9630L, 11289L, 52590L, 2261L, 10791L, \n",
      "    5979L, 2203L, 12235L, 40941L, 5630L, 11015L, 7228L, 39722L, \n",
      "    14426L, 2459L, 3989L, 7727L, 5124L, 18963L, 2200L, 7153L, \n",
      "    5227L, 10982L, 4529L, 4670L, 6112L, 17178L, 22478L, 11093L, \n",
      "    6457L, 4433L, 2154L, 23887L, 6496L, 2899L, 19350L, 7650L, \n",
      "    2850L, 2632L, 9447L, 18328L, 8603L, 37465L, 13844L, 21771L, \n",
      "    13126L, 5327L, 13725L, 13019L, 8671L, 4134L, 18838L, 33307L, \n",
      "    5699L, 6393L, 4934L, 6198L, 8733L, 2055L, 9964L, 18223L, \n",
      "    5116L, 36910L, 38415L, 20296L, 12347L, 5373L, 23563L, 1702L, \n",
      "    10806L, 3956L, 12890L, 5415L, 4058L, 41661L, 7537L, 4718L, \n",
      "    6593L, 8442L, 26125L, 6858L, 4795L, 6640L, 7162L, 10594L, \n",
      "    11938L, 60021L, 20167L, 12479L, 11345L, 8515L, 2699L, 14449L, \n",
      "    12224L, 6985L, 3238L, 47269L, 49577L, 4296L, 3171L, 1135L, \n",
      "    5615L, 9101L, 6059L, 1633L, 37607L, 18648L, 1241L, 16232L, \n",
      "    15828L, 4415L, 6474L, 11436L, 11305L, 30063L, 10197L, 4544L, \n",
      "    3277L, 6770L, 7337L, 10370L, 26926L, 10704L, 34254L, 1880L, \n",
      "    8615L, 3292L, 3021L, 14478L, 4747L, 17043L, 10959L, 2741L, \n",
      "    4357L, 22462L, 4189L, 8283L, 24535L, 14283L, 1720L, 47403L, \n",
      "    8534L, 3732L, 5472L, 38344L, 7147L, 7133L, 34828L, 1515L, \n",
      "    9301L, 11931L, 1964L, 1708L, 4340L, 5261L, 2710L, 62592L, \n",
      "    46718L, 3208L, 37829L, 21259L, 2464L, 16115L, 21472L, 33900L, \n",
      "    6875L, 6940L, 4571L, 4536L, 36397L, 18765L, 11272L, 1731L, \n",
      "    1163L, 19496L, 7201L, 5425L, 28101L, 12981L, 43896L, 4239L, \n",
      "    13143L, 7050L, 9377L, 22395L, 10325L, 12629L, 10795L, 11411L, \n",
      "    10600L, 2205L, 1629L, 2007L, 29141L)), class = \"data.frame\", row.names = c(NA, \n",
      "    -1338L)))\n",
      "\n",
      "Coefficients:\n",
      "    (Intercept)              age              bmi         children  \n",
      "       -11794.4            257.1            337.5            477.3  \n",
      "      smokeryes  regionnorthwest  regionsoutheast  regionsouthwest  \n",
      "        23847.4           -345.7          -1041.8           -968.9  \n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 调用R进行逐步回归\n",
    "import pandas as pd\n",
    "from rpy2 import robjects\n",
    "from rpy2.robjects.packages import importr\n",
    "\n",
    "stats = robjects.packages.importr('stats')\n",
    "\n",
    "insurance = pd.read_excel('data/insurance.xlsx') \n",
    "\n",
    "# 使用robjects.DataFrame创建R数据框\n",
    "rdf = robjects.DataFrame({\n",
    "    'age': robjects.IntVector(insurance['age']),\n",
    "    'sex': robjects.StrVector(insurance['sex']),\n",
    "    'bmi': robjects.IntVector(insurance['bmi']),\n",
    "    'children': robjects.IntVector(insurance['children']),\n",
    "    'smoker': robjects.StrVector(insurance['smoker']),\n",
    "    'region': robjects.StrVector(insurance['region']),\n",
    "    'charges': robjects.IntVector(insurance['charges']),\n",
    "})\n",
    "\n",
    "\n",
    "# 定义逐步回归模型\n",
    "formula = robjects.Formula('charges ~ .')\n",
    "\n",
    "lm_fit = stats.lm(formula,data=rdf)\n",
    "\n",
    "step_result = stats.step(lm_fit)\n",
    "\n",
    "# 打印逐步回归结果\n",
    "print(step_result)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "b904e8a1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"simpletable\">\n",
       "<caption>OLS Regression Results</caption>\n",
       "<tr>\n",
       "  <th>Dep. Variable:</th>        <td>charges</td>    <th>  R-squared:         </th> <td>   0.751</td> \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Model:</th>                  <td>OLS</td>      <th>  Adj. R-squared:    </th> <td>   0.750</td> \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Method:</th>            <td>Least Squares</td> <th>  F-statistic:       </th> <td>   572.7</td> \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Date:</th>             <td>周日, 28 1月 2024</td> <th>  Prob (F-statistic):</th>  <td>  0.00</td>  \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Time:</th>                <td>15:41:06</td>    <th>  Log-Likelihood:    </th> <td> -13548.</td> \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>No. Observations:</th>     <td>  1338</td>     <th>  AIC:               </th> <td>2.711e+04</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Df Residuals:</th>         <td>  1330</td>     <th>  BIC:               </th> <td>2.715e+04</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Df Model:</th>             <td>     7</td>     <th>                     </th>     <td> </td>    \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Covariance Type:</th>     <td>nonrobust</td>   <th>                     </th>     <td> </td>    \n",
       "</tr>\n",
       "</table>\n",
       "<table class=\"simpletable\">\n",
       "<tr>\n",
       "           <td></td>              <th>coef</th>     <th>std err</th>      <th>t</th>      <th>P>|t|</th>  <th>[0.025</th>    <th>0.975]</th>  \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Intercept</th>           <td>-1.199e+04</td> <td>  978.762</td> <td>  -12.250</td> <td> 0.000</td> <td>-1.39e+04</td> <td>-1.01e+04</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>smoker[T.yes]</th>       <td> 2.384e+04</td> <td>  411.856</td> <td>   57.875</td> <td> 0.000</td> <td>  2.3e+04</td> <td> 2.46e+04</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>region[T.northwest]</th> <td> -352.1821</td> <td>  476.120</td> <td>   -0.740</td> <td> 0.460</td> <td>-1286.211</td> <td>  581.847</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>region[T.southeast]</th> <td>-1034.3601</td> <td>  478.537</td> <td>   -2.162</td> <td> 0.031</td> <td>-1973.130</td> <td>  -95.590</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>region[T.southwest]</th> <td> -959.3747</td> <td>  477.778</td> <td>   -2.008</td> <td> 0.045</td> <td>-1896.656</td> <td>  -22.094</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>age</th>                 <td>  256.9736</td> <td>   11.891</td> <td>   21.610</td> <td> 0.000</td> <td>  233.646</td> <td>  280.301</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>bmi</th>                 <td>  338.6646</td> <td>   28.559</td> <td>   11.858</td> <td> 0.000</td> <td>  282.639</td> <td>  394.690</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>children</th>            <td>  474.5665</td> <td>  137.740</td> <td>    3.445</td> <td> 0.001</td> <td>  204.355</td> <td>  744.778</td>\n",
       "</tr>\n",
       "</table>\n",
       "<table class=\"simpletable\">\n",
       "<tr>\n",
       "  <th>Omnibus:</th>       <td>300.735</td> <th>  Durbin-Watson:     </th> <td>   2.089</td> \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Prob(Omnibus):</th> <td> 0.000</td>  <th>  Jarque-Bera (JB):  </th> <td> 720.516</td> \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Skew:</th>          <td> 1.212</td>  <th>  Prob(JB):          </th> <td>3.48e-157</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Kurtosis:</th>      <td> 5.654</td>  <th>  Cond. No.          </th> <td>    309.</td> \n",
       "</tr>\n",
       "</table><br/><br/>Notes:<br/>[1] Standard Errors assume that the covariance matrix of the errors is correctly specified."
      ],
      "text/plain": [
       "<class 'statsmodels.iolib.summary.Summary'>\n",
       "\"\"\"\n",
       "                            OLS Regression Results                            \n",
       "==============================================================================\n",
       "Dep. Variable:                charges   R-squared:                       0.751\n",
       "Model:                            OLS   Adj. R-squared:                  0.750\n",
       "Method:                 Least Squares   F-statistic:                     572.7\n",
       "Date:                  周日, 28 1月 2024   Prob (F-statistic):               0.00\n",
       "Time:                        15:41:06   Log-Likelihood:                -13548.\n",
       "No. Observations:                1338   AIC:                         2.711e+04\n",
       "Df Residuals:                    1330   BIC:                         2.715e+04\n",
       "Df Model:                           7                                         \n",
       "Covariance Type:            nonrobust                                         \n",
       "=======================================================================================\n",
       "                          coef    std err          t      P>|t|      [0.025      0.975]\n",
       "---------------------------------------------------------------------------------------\n",
       "Intercept           -1.199e+04    978.762    -12.250      0.000   -1.39e+04   -1.01e+04\n",
       "smoker[T.yes]        2.384e+04    411.856     57.875      0.000     2.3e+04    2.46e+04\n",
       "region[T.northwest]  -352.1821    476.120     -0.740      0.460   -1286.211     581.847\n",
       "region[T.southeast] -1034.3601    478.537     -2.162      0.031   -1973.130     -95.590\n",
       "region[T.southwest]  -959.3747    477.778     -2.008      0.045   -1896.656     -22.094\n",
       "age                   256.9736     11.891     21.610      0.000     233.646     280.301\n",
       "bmi                   338.6646     28.559     11.858      0.000     282.639     394.690\n",
       "children              474.5665    137.740      3.445      0.001     204.355     744.778\n",
       "==============================================================================\n",
       "Omnibus:                      300.735   Durbin-Watson:                   2.089\n",
       "Prob(Omnibus):                  0.000   Jarque-Bera (JB):              720.516\n",
       "Skew:                           1.212   Prob(JB):                    3.48e-157\n",
       "Kurtosis:                       5.654   Cond. No.                         309.\n",
       "==============================================================================\n",
       "\n",
       "Notes:\n",
       "[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n",
       "\"\"\""
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 选择最优模型\n",
    "best_model =  sm.formula.ols('charges ~ age + bmi + children + smoker + region',data=insurance).fit()\n",
    "best_model.summary() # 查看模型摘要"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb842688",
   "metadata": {},
   "source": [
    "### 8.6\t 逻辑回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "7fbac4ca",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy: 1.0\n",
      "Classification Report:\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       1.00      1.00      1.00        10\n",
      "           1       1.00      1.00      1.00         9\n",
      "           2       1.00      1.00      1.00        11\n",
      "\n",
      "    accuracy                           1.00        30\n",
      "   macro avg       1.00      1.00      1.00        30\n",
      "weighted avg       1.00      1.00      1.00        30\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\Program\\Anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py:444: ConvergenceWarning: lbfgs failed to converge (status=1):\n",
      "STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.\n",
      "\n",
      "Increase the number of iterations (max_iter) or scale the data as shown in:\n",
      "    https://scikit-learn.org/stable/modules/preprocessing.html\n",
      "Please also refer to the documentation for alternative solver options:\n",
      "    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression\n",
      "  n_iter_i = _check_optimize_result(\n"
     ]
    }
   ],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "from sklearn.datasets import load_iris\n",
    "from sklearn.metrics import accuracy_score, classification_report\n",
    "\n",
    "# 加载iris数据集\n",
    "iris = load_iris()\n",
    "X = iris.data\n",
    "y = iris.target\n",
    "\n",
    "# 划分数据集为训练集和测试集\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
    "\n",
    "# 创建逻辑回归模型\n",
    "model = LogisticRegression()\n",
    "\n",
    "# 在训练集上拟合模型\n",
    "model.fit(X_train, y_train)\n",
    "\n",
    "# 在测试集上进行预测\n",
    "y_pred = model.predict(X_test)\n",
    "\n",
    "# 评估模型性能\n",
    "accuracy = accuracy_score(y_test, y_pred)\n",
    "report = classification_report(y_test, y_pred)\n",
    "\n",
    "# 打印模型性能\n",
    "print(f'Accuracy: {accuracy}')\n",
    "print('Classification Report:')\n",
    "print(report)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a564f23f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
